Example #1
0
        public async Task <IActionResult> Edit(Employee_Contract employee_Contract)
        {
            ResponseHelper objHelper = new ResponseHelper();

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

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

                await employee_ContractRepository.Update(employee_Contract);

                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));
            }
        }
Example #2
0
 public async Task Insert(Employee_Contract entity)
 {
     try
     {
         entity.AddedOn = DateTime.Now;
         adbContext.employee_contract.Add(entity);
         await Task.FromResult(adbContext.SaveChanges());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
 public bool Exists(Employee_Contract entity)
 {
     try
     {
         int intCount = 0;
         if (entity.Emp_Contract_Id > 0) //Update Validation
         {
             intCount = adbContext.employee_contract.Where(w => w.Emp_Contract_Id != entity.Emp_Contract_Id && w.Emp_Id == entity.Emp_Id && w.Emp_Contract_Code == entity.Emp_Contract_Code && w.Emp_Contract_Name == entity.Emp_Contract_Name).Count();
         }
         else //Insert Validation
         {
             intCount = adbContext.employee_contract.Where(w => w.Emp_Id == entity.Emp_Id && w.Emp_Contract_Code == entity.Emp_Contract_Code && w.Emp_Contract_Name == entity.Emp_Contract_Name).Count();
         }
         return(intCount > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
        public async Task Update(Employee_Contract entity)
        {
            try
            {
                Employee_Contract lstEmp_contract = new Employee_Contract();
                lstEmp_contract = adbContext.employee_contract.Where(x => x.Emp_Contract_Id == entity.Emp_Contract_Id && x.Emp_Id == entity.Emp_Id).FirstOrDefault();
                if (lstEmp_contract != null)
                {
                    lstEmp_contract.Emp_Id                   = entity.Emp_Id;
                    lstEmp_contract.Emp_Contract_Code        = entity.Emp_Contract_Code;
                    lstEmp_contract.Emp_Contract_Name        = entity.Emp_Contract_Name;
                    lstEmp_contract.Emp_Contract_HoursDaily  = entity.Emp_Contract_HoursDaily;
                    lstEmp_contract.Emp_Contract_HoursWeekly = entity.Emp_Contract_HoursWeekly;
                    lstEmp_contract.Emp_Contract_Days        = entity.Emp_Contract_Days;
                    lstEmp_contract.Emp_Contract_Type        = entity.Emp_Contract_Type;
                    lstEmp_contract.Emp_Contract_Start       = entity.Emp_Contract_Start;
                    lstEmp_contract.Emp_Contract_End         = entity.Emp_Contract_End;
                    lstEmp_contract.Emp_Doc_Id               = entity.Emp_Doc_Id;
                    lstEmp_contract.isRequired               = entity.isRequired;
                    lstEmp_contract.Notes      = entity.Notes;
                    lstEmp_contract.Version_Id = entity.Version_Id;

                    lstEmp_contract.isActive  = entity.isActive;
                    lstEmp_contract.UpdatedBy = entity.UpdatedBy;
                    lstEmp_contract.UpdatedOn = DateTime.Now;

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