Beispiel #1
0
        public async Task <IActionResult> AddAndEditCheckListJobAdvanceOperator(CheckListJobAdvanceOperatorCustom data)
        {
            #region Authorization code
            var    identity = HttpContext.User.Identity as ClaimsIdentity;
            string id       = "";
            string role     = "";
            if (identity != null)
            {
                IEnumerable <Claim> claims = identity.Claims;
                // or
                id   = identity.Claims.Where(m => m.Type == ClaimTypes.Sid).Select(m => m.Value).FirstOrDefault();
                role = identity.Claims.Where(m => m.Type == ClaimTypes.Role).Select(m => m.Value).FirstOrDefault();
            }
            long userId = Convert.ToInt32(id);
            #endregion
            //calling CheckListJobAdvanceOperatorDAL busines layer
            CommonResponse response = new CommonResponse();
            response = checkListJobAdvanceOperator.AddAndEditCheckListJobAdvanceOperator(data, userId);

            return(Ok(response));
        }
Beispiel #2
0
        /// <summary>
        /// Add and Edit Document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditCheckListJobAdvanceOperator(CheckListJobAdvanceOperatorCustom data, long userId = 0)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var res = db.CheckListJobAdvanceOperator.Where(m => m.CheckListJobOperatorId == data.checkListJobOperatorId && m.CheckListJobAdvanceId == data.checkListJobAdvanceId).FirstOrDefault();
                if (res == null)
                {
                    try
                    {
                        CheckListJobAdvanceOperator item = new CheckListJobAdvanceOperator();
                        item.CheckListJobOperatorId = data.checkListJobOperatorId;
                        item.CheckListJobAdvanceId  = data.checkListJobAdvanceId;
                        item.OperatorId             = userId;
                        item.OperatorRemark         = data.operatorRemark;
                        item.IsActive        = true;
                        item.IsDeleted       = false;
                        item.IsAdminApproved = false;
                        item.IsJobRejected   = false;
                        item.CreatedBy       = userId;
                        item.CreatedOn       = DateTime.Now;
                        db.CheckListJobAdvanceOperator.Add(item);
                        db.SaveChanges();
                        obj.response = ResourceResponse.AddedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
                else
                {
                    try
                    {
                        res.CheckListJobOperatorId = data.checkListJobOperatorId;
                        res.CheckListJobAdvanceId  = data.checkListJobAdvanceId;
                        res.OperatorId             = userId;
                        res.OperatorRemark         = data.operatorRemark;
                        res.IsAdminApproved        = false;
                        res.IsJobRejected          = false;
                        res.JobRejectedReason      = "";
                        res.ModifiedBy             = userId;
                        res.ModifiedOn             = DateTime.Now;
                        db.SaveChanges();
                        obj.response = ResourceResponse.UpdatedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex); if (ex.InnerException != null)
                {
                    log.Error(ex.InnerException.ToString());
                }
                obj.response = ResourceResponse.ExceptionMessage;
                obj.isStatus = false;
            }
            return(obj);
        }