public IActionResult updateCommitment([FromBody] TCommitmentViewModel model)
        {
            var oCommitment = new TCommitmentViewModel();

            oCommitment.CommitmentId = model.CommitmentId;
            oCommitment.UpdatedBy    = model.UpdatedBy;

            var result = false;

            if (model.CommitmentStatus == "Success" || model.CommitmentStatus == "Fail")
            {
                result = oCommitmentBiz.UpdateCommitment(model);
                return(StatusCode(StatusCodes.Status200OK, result));
            }
            else if (model.CommitmentStatus == "Delete")
            {
                result = oCommitmentBiz.DeleteCommitment(model);
                return(StatusCode(StatusCodes.Status200OK, result));
            }
            else if (model.CommitmentStatus == "Postpone")
            {
                result = oCommitmentBiz.PostponeCommitment(model);
                return(StatusCode(StatusCodes.Status200OK, result));
            }
            return(StatusCode(StatusCodes.Status404NotFound));
        }
        public IActionResult addCommitment([FromBody] TCommitmentViewModel model)
        {
            var result = oCommitmentBiz.InsertCommitment(model);

            if (result != null)
            {
                return(StatusCode(StatusCodes.Status200OK, result));
            }
            else
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }
        }
        public IActionResult getCommitment([FromBody] TCommitmentViewModel model)
        {
            var result = oCommitmentBiz.GetCommitment().Where(x => !(x.IsDeleted == 1) && x.CreatedBy == model.CreatedBy);

            if (result != null)
            {
                return(StatusCode(StatusCodes.Status200OK, result));
            }
            else
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }
        }
Example #4
0
        public bool DeleteCommitment(TCommitmentViewModel obj)
        {
            var oCommitment = oCommitmentRepository.Get().Where(t => t.CommitmentId == obj.CommitmentId && t.IsDeleted == 0).FirstOrDefault();

            if (oCommitment != null)
            {
                oCommitment.CommitmentRemark = obj.CommitmentRemark;
                oCommitment.CommitmentStatus = db.MParentUser.Any(t => t.UserId == obj.UpdatedBy) ? "Watting for delete re-approve." : "Deleted";
                return(oCommitmentRepository.Delete(oCommitment));
            }

            return(false);
        }
Example #5
0
        public bool PostponeCommitment(TCommitmentViewModel obj) //uint commitmentId, uint? updatedBy
        {
            var oCommitment = oCommitmentRepository.Get().Where(t => t.CommitmentId == obj.CommitmentId && t.IsDeleted == 0).FirstOrDefault();

            if (oCommitment != null)
            {
                //oCommitment.CommitmentNo += 1;
                oCommitment.CommitmentStartDate = obj.CommitmentStartDate;
                oCommitment.CommitmentRemark    = obj.CommitmentRemark;
                oCommitment.CommitmentStatus    = db.MParentUser.Any(t => t.UserId == obj.UpdatedBy) ? "Watting for postpone re-approve." : "Postpone";
                return(oCommitmentRepository.Update(oCommitment));
            }

            return(false);
        }
Example #6
0
 public bool InsertCommitment(TCommitmentViewModel obj)
 {
     return(oCommitmentRepository.Insert(new TCommitment
     {
         UserId = obj.CreatedBy,
         CreatedBy = obj.CreatedBy,
         CommitmentLm = obj.DepartmentLmId,
         CommitmentName = obj.CommitmentName,
         CommitmentDescription = "",
         CommitmentRemark = "",
         CommitmentStartDate = obj.CommitmentStartDate, //DateTime.Now,
         CommitmentFinishDate = null,
         CommitmentIsDeleted = 0,
         CommitmentStatus = db.MParentUser.Any(t => t.UserId == obj.CreatedBy) ? "Watting for approve." : "In-Progress"
     }));
 }
        public IActionResult getCommitmentClosed([FromBody] TCommitmentViewModel model)
        {
            var result = oCommitmentBiz.GetCommitmentClosed().Where(x => x.CreatedBy == model.CreatedBy);

            if (model.DepartmentWigName != null && model.DepartmentLmName != null)
            {
                result = result.Where(x => x.DepartmentWigName == model.DepartmentWigName && x.DepartmentLmName == model.DepartmentLmName);
            }
            else if (model.DepartmentWigName != null && model.DepartmentLmName == null)
            {
                result = result.Where(x => x.DepartmentWigName == model.DepartmentWigName);
            }

            if (result != null)
            {
                return(StatusCode(StatusCodes.Status200OK, result));
            }
            else
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }
        }
Example #8
0
        public bool UpdateCommitment(TCommitmentViewModel obj)
        {
            var oCommitment = oCommitmentRepository.Get().Where(t => t.CommitmentId == obj.CommitmentId && t.IsDeleted == 0).FirstOrDefault();

            if (oCommitment != null)
            {
                if (obj.CommitmentStatus == "Success")
                {
                    oCommitment.CommitmentFinishDate = DateTime.Now;
                    oCommitment.CommitmentStatus     = db.MParentUser.Any(t => t.UserId == obj.UpdatedBy) ? "Waiting for " + obj.CommitmentStatus + " re-approve." : obj.CommitmentStatus;
                    return(oCommitmentRepository.Update(oCommitment));
                }
                else if (obj.CommitmentStatus == "Fail")
                {
                    oCommitment.CommitmentRemark = obj.CommitmentRemark;
                    oCommitment.CommitmentStatus = obj.CommitmentStatus;
                    return(oCommitmentRepository.Update(oCommitment));
                }
            }

            return(false);
        }