Пример #1
0
        public async Task <IActionResult> Edit(Job_DiscriptionView job_description)
        {
            ResponseHelper objHelper = new ResponseHelper();

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

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

                await job_descriptionRepository.Update(job_description);

                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));
            }
        }
Пример #2
0
        public async Task Update(Job_DiscriptionView entity)
        {
            try
            {
                var vList = adbContext.job_description.Where(x => x.JD_Id == entity.JD_Id).FirstOrDefault();
                if (vList != null)
                {
                    vList.Company_Id     = entity.Company_Id;
                    vList.Dept_Id        = entity.Dept_Id;
                    vList.Desig_Id       = entity.Desig_Id;
                    vList.JD_Code        = entity.JD_Code.Trim();
                    vList.JD_Name        = entity.JD_Name.Trim();
                    vList.JD_Description = entity.JD_Description;
                    vList.Notes          = entity.Notes;

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

                    adbContext.job_description.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(Job_DiscriptionView entity)
        {
            try
            {
                var vList = new Job_Description
                {
                    Company_Id     = entity.Company_Id,
                    Dept_Id        = entity.Dept_Id,
                    Desig_Id       = entity.Desig_Id,
                    JD_Code        = entity.JD_Code.Trim(),
                    JD_Name        = entity.JD_Name.Trim(),
                    JD_Description = entity.JD_Description,
                    Notes          = entity.Notes,

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

                adbContext.job_description.Add(vList);

                await Task.FromResult(adbContext.SaveChanges());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public bool Exists(Job_DiscriptionView entity)
        {
            int intCount = 0;

            if (entity.JD_Id > 0) //Update Validation
            {
                intCount = adbContext.job_description.Where(w => w.Company_Id == entity.Company_Id && w.JD_Id != entity.JD_Id && (w.JD_Code == entity.JD_Code || w.JD_Name == entity.JD_Name)).Count();
            }
            else //Insert Validation
            {
                intCount = adbContext.job_description.Where(w => w.Company_Id == entity.Company_Id && (w.JD_Code == entity.JD_Code || w.JD_Name == entity.JD_Name)).Count();
            }
            return(intCount > 0 ? true : false);
        }