Пример #1
0
        public ActionResult Insert_Quality(QualityViewModel qViewModel)
        {
            try
            {
                qViewModel.Quality.CreatedBy = ((UserInfo)Session["User"]).UserId;

                qViewModel.Quality.CreatedBy = ((UserInfo)Session["User"]).UserId;

                qViewModel.Quality.UpdatedBy = ((UserInfo)Session["User"]).UserId;

                qViewModel.Quality.CreatedOn = DateTime.Now;

                qViewModel.Quality.UpdatedOn = DateTime.Now;

                qViewModel.Quality.Quality_Id = _qualityMan.Insert_Quality(qViewModel.Quality);

                qViewModel.Friendly_Message.Add(MessageStore.Get("Q011"));
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Insert " + ex.ToString());
            }

            return(Json(qViewModel));
        }
Пример #2
0
        public JsonResult Get_Qualities(QualityViewModel qViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            try
            {
                pager = qViewModel.Pager;

                if (qViewModel.Filter.Yarn_Type_Id > 0)
                {
                    qViewModel.Quality_Grid = _qualityMan.Get_Quality_By_Yarn_Types(qViewModel.Filter.Yarn_Type_Id, ref pager);
                }
                else
                {
                    qViewModel.Quality_Grid = _qualityMan.Get_Qualities(ref pager);
                }

                qViewModel.Pager = pager;

                qViewModel.Pager.PageHtmlString = PageHelper.NumericPager("javascript:PageMore({0})", qViewModel.Pager.TotalRecords, qViewModel.Pager.CurrentPage + 1, qViewModel.Pager.PageSize, 10, true);
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Get_Qualities " + ex.ToString());
            }

            finally
            {
                pager = null;
            }
            return(Json(qViewModel, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public async Task Post()
        {
            QualityViewModel VM = GenerateTestModel();
            var response        = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json"));

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }
Пример #4
0
        public void Fail_Return_Success()
        {
            //Setup
            string ApiVersion = "V1";
            int    StatusCode = 200;
            string Message    = "OK";

            QualityViewModel viewModel = new QualityViewModel();
            ResultFormatter  formatter = new ResultFormatter(ApiVersion, StatusCode, Message);

            System.ComponentModel.DataAnnotations.ValidationContext validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(viewModel);

            var errorData = new
            {
                WarningError = "Format Not Match"
            };

            string error     = JsonConvert.SerializeObject(errorData);
            var    exception = new ServiceValidationException(validationContext, new List <ValidationResult>()
            {
                new ValidationResult(error, new List <string>()
                {
                    "WarningError"
                })
            });

            //Act
            var result = formatter.Fail(exception);

            //Assert
            Assert.True(0 < result.Count());
        }
Пример #5
0
        public IActionResult Create(QualityViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            //if (string.IsNullOrEmpty(AuthContextService.CurrentUser.SchoolUuid))
            //{
            //    response.SetFailed("");
            //    return Ok(response);
            //}
            using (_dbContext)
            {
                var entity = new HaiKanStudentDiningManagementSystem.Api.Entities.Quality();
                entity.QualityUuid   = Guid.NewGuid();
                entity.IsDelete      = 0;
                entity.AddTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                entity.FlieName      = model.FlieName;
                entity.JianJie       = model.JianJie;
                entity.SchoolUuid    = model.SchoolUuid;
                entity.Accessory     = model.Accessory;
                entity.EffectiveTime = Convert.ToDateTime(model.EffectiveTime).ToString("yyyy-MM-dd");
                //entity.SchoolUuid = Guid.NewGuid();
                _dbContext.Quality.Add(entity);
                _dbContext.SaveChanges();

                response.SetSuccess();
                return(Ok(response));
            }
        }
Пример #6
0
        public QualityViewModel MapToViewModel(Quality model)
        {
            QualityViewModel viewModel = new QualityViewModel();

            PropertyCopier <Quality, QualityViewModel> .Copy(model, viewModel);

            return(viewModel);
        }
Пример #7
0
        public Quality MapToModel(QualityViewModel viewModel)
        {
            Quality model = new Quality();

            PropertyCopier <QualityViewModel, Quality> .Copy(viewModel, model);

            return(model);
        }
Пример #8
0
        public ActionResult Index(QualityViewModel qViewModel)
        {
            qViewModel.Yarn_Types = _qualityMan.Get_Yarn_Types();

            qViewModel.Weaves_Types = _qualityMan.Get_Weave_Types();

            return(View(qViewModel));
        }
Пример #9
0
        public JsonResult Get_Grid_By_Yarn_Type(QualityViewModel qViewModel)
        {
            PaginationInfo Pager = new PaginationInfo();

            Pager.IsPagingRequired = false;

            if (qViewModel.Filter.Yarn_Type_Id > 0)
            {
                qViewModel.Quality_Grid = _qualityMan.Get_Grid_By_Yarn_Type(qViewModel.Filter.Yarn_Type_Id);
            }

            return(Json(qViewModel, JsonRequestBehavior.AllowGet));
        }
 public async Task <IHttpActionResult> Get(string fType, string nameContain, string year, string month)
 {
     System.Diagnostics.Debug.WriteLine(nameContain + ": " + year + '-' + month);
     if (fType == "MTDChart")
     {
         return(Ok(await QualityViewModel.MapFromAsync(db.ScrapDailyByPlants.Where(x => x.PlantCode.Equals(nameContain) && x.Year.Equals(year) && x.Month.Equals(month)).OrderBy(o => o.Day).ToList())));
     }
     else if (fType == "Snapshot")
     {
         return(Ok(await QualityViewModel.MapFromAsync(db.ScrapMonthlyByPlants.Where(x => x.PlantCode.Equals(nameContain) && x.Year.Equals(year) && x.Month.Equals(month)).ToList())));
     }
     else
     {
         return(null);
     }
 }
Пример #11
0
        public ActionResult View_Quality(QualityViewModel qViewModel)
        {
            ViewBag.Title = "KPCL ERP :: Search";

            try
            {
                qViewModel.Quality = _qualityMan.Get_Quality_By_Id(qViewModel.Quality.Quality_Id);
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Search " + ex.ToString());
            }

            return(View("View", qViewModel));
        }
 public async Task <IHttpActionResult> Get(string fType, string nameContain, string year, string month, string day)
 {
     if (nameContain == "All")
     {
         return(Ok(await QualityViewModel.MapFromAsync(db.ScrapStages.Where(x => x.PlantCode.Contains("") && x.DateDisposed.Equals(year + month + day)).ToList())));
     }
     else
     {
         if (fType == "MonthSnapShot")
         {
             return(Ok(await QualityViewModel.MapFromAsync(db.ScrapStages.Where(x => (x.CompanyCode.Equals(nameContain) || x.PlantCode.Equals(nameContain)) && x.DateDisposed.Substring(0, 6).Equals(year + month)).ToList())));
         }
         else
         {
             return(Ok(await QualityViewModel.MapFromAsync(db.ScrapStages.Where(x => (x.CompanyCode.Equals(nameContain) || x.PlantCode.Equals(nameContain)) && x.DateDisposed.Equals(year + month + day)).ToList())));
         }
     }
 }
Пример #13
0
        public PartialViewResult Printable_Quality(int quality_Id)
        {
            ViewBag.Title = "KPCL ERP :: Print";

            QualityViewModel qViewModel = new QualityViewModel();

            qViewModel.Quality.Quality_Id = quality_Id;

            try
            {
                qViewModel.Quality = _qualityMan.Get_Quality_By_Id(qViewModel.Quality.Quality_Id);
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Search " + ex.ToString());
            }

            return(PartialView("_PrintableView", qViewModel));
        }
Пример #14
0
        public ActionResult Get_Quality_By_Id(QualityViewModel qViewModel)
        {
            try
            {
                qViewModel.Quality = _qualityMan.Get_Quality_By_Id(qViewModel.Quality.Quality_Id);

                qViewModel.Quality_Application_Mapping_Grid = _qualityMan.Get_Quality_Application_By_Id(qViewModel.Quality.Quality_Id);

                qViewModel.Quality_Market_Segment_Mapping_Grid = _qualityMan.Get_Quality_Market_Segment_By_Id(qViewModel.Quality.Quality_Id);

                qViewModel.Yarn_Types = _qualityMan.Get_Yarn_Types();

                qViewModel.Weaves_Types = _qualityMan.Get_Weave_Types();
            }

            catch (Exception ex)
            {
                Logger.Error("Quality Controller - Get_Quality_By_Id " + ex.ToString());
            }

            return(View("Index", qViewModel));
        }
Пример #15
0
        public ActionResult Insert_Segment(QualityViewModel qViewModel)
        {
            try
            {
                qViewModel.Quality_Market_Segment_Mapping.CreatedBy = 1;

                qViewModel.Quality_Market_Segment_Mapping.UpdatedBy = 1;

                _qualityMan.Insert_Segment(qViewModel.Quality_Market_Segment_Mapping);

                qViewModel.Quality_Market_Segment_Mapping_Grid = _qualityMan.Get_Quality_Market_Segment_By_Id(qViewModel.Quality_Market_Segment_Mapping.Quality_Id);

                qViewModel.Friendly_Message.Add(MessageStore.Get("QS011"));
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Insert_Segment" + ex.ToString());
            }

            return(Json(qViewModel));
        }
Пример #16
0
        public ActionResult Search(QualityViewModel qViewModel)
        {
            qViewModel.Yarn_Types = _qualityMan.Get_Yarn_Types();

            return(View("Search", qViewModel));
        }
Пример #17
0
 public PartialViewResult Load_Quality(QualityViewModel qViewModel)
 {
     return(PartialView("_Index", qViewModel));
 }
Пример #18
0
        public JsonResult Delete_Quality_Market_Segment_By_Id(int quality_Market_Segment_Id, QualityViewModel qViewModel)
        {
            try
            {
                _qualityMan.Delete_Quality_Market_Segment_By_Id(quality_Market_Segment_Id);

                qViewModel.Friendly_Message.Add(MessageStore.Get("QS012"));
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Delete_Quality_Market_Segment_By_Id" + ex.ToString());
            }
            return(Json(qViewModel, JsonRequestBehavior.AllowGet));
        }