Example #1
0
        public async Task <ActionResult> SaveModify(ProductionLineViewModel model)
        {
            using (ProductionLineServiceClient client = new ProductionLineServiceClient())
            {
                MethodReturnResult <ProductionLine> result = await client.GetAsync(model.Code);

                if (result.Code == 0)
                {
                    result.Data.Name         = model.Name;
                    result.Data.LocationName = model.LocationName;
                    result.Data.Description  = model.Description;
                    result.Data.Attr1        = model.Attr1;
                    result.Data.Editor       = User.Identity.Name;
                    result.Data.EditTime     = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(FMMResources.StringResource.ProductionLine_SaveModify_Success
                                                    , model.Code);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Example #2
0
        //
        // GET: /FMM/ProductionLine/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (ProductionLineServiceClient client = new ProductionLineServiceClient())
            {
                MethodReturnResult <ProductionLine> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    ProductionLineViewModel viewModel = new ProductionLineViewModel()
                    {
                        Code         = result.Data.Key,
                        Name         = result.Data.Name,
                        LocationName = result.Data.LocationName,
                        Attr1        = result.Data.Attr1,
                        CreateTime   = result.Data.CreateTime,
                        Creator      = result.Data.Creator,
                        Description  = result.Data.Description,
                        Editor       = result.Data.Editor,
                        EditTime     = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Example #3
0
        public async Task <ActionResult> Save(ProductionLineViewModel model)
        {
            using (ProductionLineServiceClient client = new ProductionLineServiceClient())
            {
                ProductionLine obj = new ProductionLine()
                {
                    Key          = model.Code,
                    Name         = model.Name,
                    LocationName = model.LocationName,
                    Attr1        = model.Attr1,
                    Description  = model.Description,
                    Editor       = User.Identity.Name,
                    EditTime     = DateTime.Now,
                    CreateTime   = DateTime.Now,
                    Creator      = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.ProductionLine_Save_Success
                                                , model.Code);
                }
                return(Json(rst));
            }
        }
        public ActionResult SaveProductionLine(ProductionLineViewModel productionLineViewModel)
        {
            bool isSuccess = false;

            if (ModelState.IsValid)
            {
                try
                {
                    ProductionLineDTO dto = new ProductionLineDTO();
                    AutoMapper.Mapper.Map(productionLineViewModel, dto);
                    isSuccess = _productionLineBusiness.SaveUnit(dto, UserId, OrgId);
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                }
            }
            return(Json(isSuccess));
        }