Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(Employee_Address employee_Address)
        {
            ResponseHelper objHelper = new ResponseHelper();

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

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

                await employee_AddressRepository.Update(employee_Address);

                objHelper.Status  = StatusCodes.Status200OK;
                objHelper.Message = "Saved Successfully";
                return(Ok(objHelper));
            }
            catch
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = "Get Unsuccessful";
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
Ejemplo n.º 2
0
 public async Task Insert(Employee_Address entity)
 {
     try
     {
         entity.AddedOn = DateTime.Now;
         adbContext.employee_address.Add(entity);
         await Task.FromResult(adbContext.SaveChanges());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
 public bool Exists(Employee_Address entity)
 {
     try
     {
         int intCount = 0;
         if (entity.Emp_Address_Id > 0) //Update Validation
         {
             intCount = adbContext.employee_address.Where(w => w.Emp_Address_Id != entity.Emp_Address_Id && w.Emp_Id == entity.Emp_Id && w.Address1 == entity.Address1 && w.Address2 == entity.Address2 && w.Address3 == entity.Address3 && w.Address4 == entity.Address4).Count();
         }
         else //Insert Validation
         {
             intCount = adbContext.employee_address.Where(w => w.Address1 == entity.Address1 && w.Address2 == entity.Address2 && w.Address3 == entity.Address3 && w.Address4 == entity.Address4).Count();
         }
         return(intCount > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
        public async Task Update(Employee_Address entity)
        {
            try
            {
                //Update Old Department
                var vList = adbContext.employee_address.Where(w => w.Emp_Id == entity.Emp_Id).FirstOrDefault();
                if (vList != null)
                {
                    vList.Emp_Id       = entity.Emp_Id;
                    vList.Address_Type = entity.Address_Type;
                    vList.Address1     = entity.Address1;
                    vList.Address2     = entity.Address2;
                    vList.Address3     = entity.Address3;
                    vList.Address4     = entity.Address4;
                    vList.PostCode     = entity.PostCode;
                    vList.City         = entity.City;
                    vList.State        = entity.State;
                    vList.Country      = entity.Country;
                    vList.LandlineNo   = entity.LandlineNo;
                    vList.isDefault    = entity.isDefault;
                    vList.Emp_Doc_Id   = entity.Emp_Doc_Id;
                    vList.isActive     = entity.isActive;
                    vList.UpdatedBy    = entity.UpdatedBy;
                    vList.UpdatedOn    = DateTime.Now;

                    adbContext.employee_address.Update(vList);
                    await Task.FromResult(adbContext.SaveChanges());
                }
                else
                {
                    throw new Exception("Data Not Available");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }