コード例 #1
0
        public async Task <IActionResult> Edit(Email_ConfigView Email_Config)
        {
            ResponseHelper objHelper = new ResponseHelper();

            if (!ModelState.IsValid)
            {
                objHelper.Status  = StatusCodes.Status424FailedDependency;
                objHelper.Message = ModelException.Errors(ModelState);
                return(BadRequest(objHelper));
            }

            try
            {
                if (Email_ConRepo.Exists(Email_Config))
                {
                    objHelper.Status  = StatusCodes.Status200OK;
                    objHelper.Message = "Data already available";
                    return(Ok(objHelper));
                }

                await Email_ConRepo.Update(Email_Config);

                objHelper.Status  = StatusCodes.Status200OK;
                objHelper.Message = "Saved Successfully";
                return(Ok(objHelper));
            }
            catch (Exception ex)
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
コード例 #2
0
        public async Task Update(Email_ConfigView entity)
        {
            try
            {
                var vList = adbContext.email_config.Where(x => x.Email_Config_Id == entity.Email_Config_Id).FirstOrDefault();
                if (vList == null)
                {
                    throw new RecoredNotFoundException("Data Not Available");
                }

                vList.Company_Id     = entity.Company_Id;
                vList.Email_Host     = entity.Email_Host;
                vList.Email_Port     = entity.Email_Port;
                vList.Email_UserName = entity.Email_UserName;
                vList.EnableSSL      = entity.EnableSSL;
                vList.isActive       = entity.isActive;
                vList.UpdatedBy      = entity.UpdatedBy;
                vList.UpdatedOn      = DateTime.Now;

                adbContext.email_config.Update(vList);
                await Task.FromResult(adbContext.SaveChanges());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public async Task <IActionResult> Add(Email_ConfigView Email_Config)
        {
            ResponseHelper objHelper = new ResponseHelper();

            if (!ModelState.IsValid)
            {
                objHelper.Status  = StatusCodes.Status424FailedDependency;
                objHelper.Message = "Invalid Model State";
                return(BadRequest(objHelper));
            }

            try
            {
                if (Email_ConRepo.Exists(Email_Config))
                {
                    objHelper.Status  = StatusCodes.Status200OK;
                    objHelper.Message = "Data already available";
                    return(Ok(objHelper));
                }

                await Email_ConRepo.Insert(Email_Config);

                objHelper.Status  = StatusCodes.Status200OK;
                objHelper.Message = "Saved Successfully";
                objHelper.Data    = Email_Config;
                return(Ok(objHelper));
            }
            catch
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = "Save Unsuccessful";
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
コード例 #4
0
        public async Task Update(Email_ConfigView entity)
        {
            var vList = new Email_Config
            {
                Company_Id     = entity.Company_Id,
                Email_Host     = entity.Email_Host,
                Email_Port     = entity.Email_Port,
                Email_UserName = entity.Email_UserName,
                EnableSSL      = entity.EnableSSL,
                isActive       = entity.isActive,
                UpdatedBy      = entity.UpdatedBy,
                UpdatedOn      = DateTime.Now
            };

            adbContext.email_config.Update(vList);
            await Task.FromResult(adbContext.SaveChanges());
        }
コード例 #5
0
 public bool Exists(Email_ConfigView entity)
 {
     try
     {
         int intCount = 0;
         if (entity.Email_Config_Id > 0) //Update Validation
         {
             intCount = adbContext.email_config.Where(w => w.Company_Id == entity.Company_Id && w.Email_Config_Id != entity.Email_Config_Id).Count();
         }
         else //Insert Validation
         {
             intCount = adbContext.email_config.Where(w => w.Company_Id == entity.Company_Id).Count();
         }
         return(intCount > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #6
0
 public async Task Insert(Email_ConfigView entity)
 {
     try
     {
         //Insert New Email Config
         var vList = new Email_Config
         {
             Company_Id     = entity.Company_Id,
             Email_Host     = entity.Email_Host,
             Email_Port     = entity.Email_Port,
             Email_UserName = entity.Email_UserName,
             EnableSSL      = entity.EnableSSL,
             isActive       = entity.isActive,
             AddedBy        = entity.AddedBy,
             AddedOn        = DateTime.Now
         };
         adbContext.email_config.Add(vList);
         await Task.FromResult(adbContext.SaveChanges());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }