1. RegistrationController(web Api controller)
using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.Interfaces;
using LaySous.CineTot.ServiceAPI.Models;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace LaySous.CineTot.ServiceAPI.Controllers
{
public class RegistrationController : ApiController
{
static readonly IRegistration oRegistration = new MRegistration();
[HttpPut]
public CServerMessage VerifyUserEmail(CVerifyEmailData VerifyEmailData)
{
return oRegistration.VerifyEmail(VerifyEmailData);
}
}
}
2.IRegistrations
using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LaySous.CineTot.ServiceAPI.Interfaces
{
public interface IRegistration
{
CServerMessage VerifyEmail(CVerifyEmailData VerifyEmailData);
}
}
3.CRegReturn.cs
using LaySous.CineTot.ServiceAPI.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LaySous.CineTot.ServiceAPI.POCO
{
public class CServerMessage
{
public string Msg;
public string ExMsg;
}
public class CVerifyEmailData
{
public string eMailID;
public string VerifyCode;
public DateTime DateVerified;
}
}
4. MRegistration
using LaySous.CineTot.ServiceAPI.Interfaces;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Linq;
using LaySous.CineTot.ServiceAPI.Entities;
using System.Collections.Generic;
namespace LaySous.CineTot.ServiceAPI.Models
{
public class MRegistration : IRegistration
{
public CServerMessage VerifyEmail(CVerifyEmailData VerifyEmailData)
{
FytotCtx oDataContext = null;
CServerMessage oServerMessage = null;
Registrations oRegistrations = null;
try
{
oServerMessage = new CServerMessage();
oServerMessage.Msg = CCommon.EnumMessages.FAILED.ToString();
oDataContext = new FytotCtx();
//oRegistrations = oDataContext.Registrations.Where(R => (R.eMailID.Trim().ToLower() == VerifyEmailData.eMailID.Trim().ToLower()) && (R.eMailVerificationCode == VerifyEmailData.VerifyCode)).FirstOrDefault();
oRegistrations = oDataContext.Registrations.Where(R => (R.eMailID.Trim().ToLower() == VerifyEmailData.eMailID.Trim().ToLower())).FirstOrDefault();
if (oRegistrations != null)
{
if (oRegistrations.eMailVerificationCode == VerifyEmailData.VerifyCode)
{
oDataContext.Registrations.Attach(oRegistrations);
oRegistrations.eMailVerified = "Y";
oRegistrations.eMailVerificationCode = null;
oRegistrations.IsQCVerified_ = "Y";
oRegistrations.DateModified = VerifyEmailData.DateVerified;
oDataContext.SaveChanges();
oServerMessage.Msg = CCommon.EnumMessages.SUCCESS.ToString();
}
else if (oRegistrations.eMailVerified == "Y")
{
oServerMessage.Msg = CCommon.EnumMessages.EMAIL_ALREADY_VERIFIED.ToString();
}
else
{
oServerMessage.Msg = CCommon.EnumMessages.INVALID_EMAIL_VERIFYCODE.ToString();
}
}
else
{
oServerMessage.Msg = CCommon.EnumMessages.INVALID_EMAIL.ToString();
}
}
catch (Exception oEx)
{
oServerMessage.Msg = CCommon.EnumMessages.EXCEPTION.ToString();
oServerMessage.ExMsg = oEx.Message.ToString();
}
finally
{
oDataContext = null;
oRegistrations = null;
}
return oServerMessage;
}
}
}
using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.Interfaces;
using LaySous.CineTot.ServiceAPI.Models;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace LaySous.CineTot.ServiceAPI.Controllers
{
public class RegistrationController : ApiController
{
static readonly IRegistration oRegistration = new MRegistration();
[HttpPut]
public CServerMessage VerifyUserEmail(CVerifyEmailData VerifyEmailData)
{
return oRegistration.VerifyEmail(VerifyEmailData);
}
}
}
2.IRegistrations
using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LaySous.CineTot.ServiceAPI.Interfaces
{
public interface IRegistration
{
CServerMessage VerifyEmail(CVerifyEmailData VerifyEmailData);
}
}
3.CRegReturn.cs
using LaySous.CineTot.ServiceAPI.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LaySous.CineTot.ServiceAPI.POCO
{
public class CServerMessage
{
public string Msg;
public string ExMsg;
}
public class CVerifyEmailData
{
public string eMailID;
public string VerifyCode;
public DateTime DateVerified;
}
}
4. MRegistration
using LaySous.CineTot.ServiceAPI.Interfaces;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Linq;
using LaySous.CineTot.ServiceAPI.Entities;
using System.Collections.Generic;
namespace LaySous.CineTot.ServiceAPI.Models
{
public class MRegistration : IRegistration
{
public CServerMessage VerifyEmail(CVerifyEmailData VerifyEmailData)
{
FytotCtx oDataContext = null;
CServerMessage oServerMessage = null;
Registrations oRegistrations = null;
try
{
oServerMessage = new CServerMessage();
oServerMessage.Msg = CCommon.EnumMessages.FAILED.ToString();
oDataContext = new FytotCtx();
//oRegistrations = oDataContext.Registrations.Where(R => (R.eMailID.Trim().ToLower() == VerifyEmailData.eMailID.Trim().ToLower()) && (R.eMailVerificationCode == VerifyEmailData.VerifyCode)).FirstOrDefault();
oRegistrations = oDataContext.Registrations.Where(R => (R.eMailID.Trim().ToLower() == VerifyEmailData.eMailID.Trim().ToLower())).FirstOrDefault();
if (oRegistrations != null)
{
if (oRegistrations.eMailVerificationCode == VerifyEmailData.VerifyCode)
{
oDataContext.Registrations.Attach(oRegistrations);
oRegistrations.eMailVerified = "Y";
oRegistrations.eMailVerificationCode = null;
oRegistrations.IsQCVerified_ = "Y";
oRegistrations.DateModified = VerifyEmailData.DateVerified;
oDataContext.SaveChanges();
oServerMessage.Msg = CCommon.EnumMessages.SUCCESS.ToString();
}
else if (oRegistrations.eMailVerified == "Y")
{
oServerMessage.Msg = CCommon.EnumMessages.EMAIL_ALREADY_VERIFIED.ToString();
}
else
{
oServerMessage.Msg = CCommon.EnumMessages.INVALID_EMAIL_VERIFYCODE.ToString();
}
}
else
{
oServerMessage.Msg = CCommon.EnumMessages.INVALID_EMAIL.ToString();
}
}
catch (Exception oEx)
{
oServerMessage.Msg = CCommon.EnumMessages.EXCEPTION.ToString();
oServerMessage.ExMsg = oEx.Message.ToString();
}
finally
{
oDataContext = null;
oRegistrations = null;
}
return oServerMessage;
}
}
}
No comments:
Post a Comment