Ejemplo n.º 1
0
        public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            MaterialPlanHeader pd = new MaterialPlanHeaderService(_unitOfWork).Find(Id);

            if (ModelState.IsValid)
            {
                pd.ReviewCount = (pd.ReviewCount ?? 0) + 1;
                pd.ReviewBy   += User.Identity.Name + ", ";

                _MaterialPlanHeaderService.Update(pd);

                _unitOfWork.Save();

                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = pd.DocTypeId,
                    DocId        = pd.MaterialPlanHeaderId,
                    ActivityType = (int)ActivityTypeContants.Reviewed,
                    UserRemark   = UserRemark,
                    DocNo        = pd.DocNo,
                    DocDate      = pd.DocDate,
                    DocStatus    = pd.Status,
                }));

                return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record reviewed successfully."));
            }

            return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Error in reviewing."));
        }
        public ActionResult Submitted(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            MaterialPlanHeader pd = new MaterialPlanHeaderService(_unitOfWork).Find(Id);

            if (ModelState.IsValid)
            {
                if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin"))
                {
                    SqlParameter SqlMaterialPlanHeaderId = new SqlParameter("@MaterialPlanHeaderId", Id);
                    db.Database.SqlQuery <int>("" + ConfigurationManager.AppSettings["DataBaseSchema"] + ".sp_UpdateMaterialPlanForSaleOrder @MaterialPlanHeaderId", SqlMaterialPlanHeaderId).FirstOrDefault();


                    pd.Status   = (int)StatusConstants.Submitted;
                    pd.ReviewBy = null;

                    _MaterialPlanHeaderService.Update(pd);

                    _unitOfWork.Save();


                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = pd.DocTypeId,
                        DocId        = pd.MaterialPlanHeaderId,
                        ActivityType = (int)ActivityTypeContants.Submitted,
                        UserRemark   = UserRemark,
                        DocNo        = pd.DocNo,
                        DocDate      = pd.DocDate,
                        DocStatus    = pd.Status,
                    }));

                    //SendEmail_PODrafted(Id);
                    return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record submitted successfully."));
                }
                else
                {
                    return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Record can be submitted by user " + pd.ModifiedBy + " only."));
                }
            }

            return(View());
        }