Beispiel #1
0
        public async Task Insert(ProbationView entity)
        {
            try
            {
                //Insert New Probation
                var vList = new Probation
                {
                    Prob_Id           = entity.Prob_Id,
                    Company_Id        = entity.Company_Id,
                    Prob_Code         = entity.Prob_Code,
                    Prob_Name         = entity.Prob_Name,
                    Prob_Description  = entity.Prob_Description,
                    Prob_DurationUnit = entity.Prob_DurationUnit,
                    Prob_Duration     = entity.Prob_Duration,
                    Notes             = entity.Notes,

                    isActive = entity.isActive,
                    AddedBy  = entity.AddedBy,
                    AddedOn  = DateTime.Now
                };

                adbContext.probation.Add(vList);
                await Task.FromResult(adbContext.SaveChanges());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public async Task Update(ProbationView entity)
        {
            var lstProb = adbContext.probation.Where(x => x.Prob_Id == entity.Prob_Id).FirstOrDefault();

            if (lstProb != null)
            {
                try
                {
                    //lstProb.Prob_Id = entity.Prob_Id;
                    lstProb.Company_Id        = entity.Company_Id;
                    lstProb.Prob_Code         = entity.Prob_Code;
                    lstProb.Prob_Name         = entity.Prob_Name;
                    lstProb.Prob_Description  = entity.Prob_Description;
                    lstProb.Prob_DurationUnit = entity.Prob_DurationUnit;
                    lstProb.Prob_Duration     = entity.Prob_Duration;

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

                    adbContext.probation.Update(lstProb);

                    await Task.FromResult(adbContext.SaveChanges());
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(ProbationView probation)
        {
            ResponseHelper objHelper = new ResponseHelper();

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

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

                await probationRepository.Update(probation);

                objHelper.Status  = StatusCodes.Status200OK;
                objHelper.Message = "Saved Successfully";
                return(Ok(objHelper));
            }
            catch
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = "Save Unsuccessful";
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
Beispiel #4
0
 public bool Exists(ProbationView entity)
 {
     try
     {
         int intCount = 0;
         if (entity.Prob_Id > 0)
         {
             intCount = adbContext.probation.Where(w => w.Prob_Id != entity.Prob_Id && (w.Prob_Code == entity.Prob_Code || w.Prob_Name == entity.Prob_Name)).Count();
         }
         else
         {
             intCount = adbContext.probation.Where(w => w.Prob_Code == entity.Prob_Code || w.Prob_Name == entity.Prob_Name).Count();
         }
         return(intCount > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }