예제 #1
0
        public async Task <IActionResult> Edit(Employee_Reference employee_Reference)
        {
            ResponseHelper objHelper = new ResponseHelper();

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

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

                await employee_ReferenceRepository.Update(employee_Reference);

                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));
            }
        }
예제 #2
0
        public async Task Update(Employee_Reference entity)
        {
            try
            {
                var vList = adbContext.employee_reference.Where(x => x.Emp_Ref_Id == entity.Emp_Ref_Id && x.Emp_Id == entity.Emp_Id).FirstOrDefault();
                if (vList != null)
                {
                    vList.Emp_Id           = entity.Emp_Id;
                    vList.Ref_Name         = entity.Ref_Name;
                    vList.Ref_ContactNo    = entity.Ref_ContactNo;
                    vList.Ref_Relationship = entity.Ref_Relationship;

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

                    adbContext.employee_reference.Update(vList);
                    await Task.FromResult(adbContext.SaveChanges());
                }
                else
                {
                    throw new Exception("Data Not Available");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
 public async Task Insert(Employee_Reference entity)
 {
     try
     {
         entity.AddedOn = DateTime.Now;
         adbContext.employee_reference.Add(entity);
         await Task.FromResult(adbContext.SaveChanges());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
 public bool Exists(Employee_Reference entity)
 {
     try
     {
         int intCount = 0;
         if (entity.Emp_Ref_Id > 0) //Update Validation
         {
             intCount = adbContext.employee_reference.Where(w => w.Emp_Ref_Id != entity.Emp_Ref_Id && w.Emp_Id == entity.Emp_Id && w.Ref_Name == entity.Ref_Name && w.Ref_ContactNo == entity.Ref_ContactNo && w.Ref_Relationship == entity.Ref_Relationship).Count();
         }
         else //Insert Validation
         {
             intCount = adbContext.employee_reference.Where(w => w.Emp_Id == entity.Emp_Id && w.Ref_Name == entity.Ref_Name && w.Ref_ContactNo == entity.Ref_ContactNo && w.Ref_Relationship == entity.Ref_Relationship).Count();
         }
         return(intCount > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }