Example #1
0
        private void Process(ActionEnum action, string type = null)
        {
            switch (action)
            {
            case ActionEnum.Create:
                var material = Read <Material>();
                #region ex
                //var userService
                //    = new UserService(new UserRepository(new BuildingContext()));

                //var assembly = Assembly.LoadFile();
                //var currentAssembly = Assembly.GetExecutingAssembly();
                //var refAssemblies = currentAssembly.GetReferencedAssemblies();

                //var bllAssemblyName =
                //    refAssemblies.FirstOrDefault
                //    (assem => assem.Name == "BLL");

                //var bllAssembly = Assembly.Load(bllAssemblyName);

                //var userServiceType =
                //    bllAssembly.GetType("BLL.Services.UserService");

                //var userService =
                //    (UserService)Activator.CreateInstance(userServiceType);
                #endregion
                materialService.Create(material);
                break;

            case ActionEnum.Read:
                var materialRead = materialService.Read(int.Parse(type));
                Write(materialRead);
                break;

            case ActionEnum.ReadAll:
                var materialReadAll = materialService.ReadAll();
                WriteAll(materialReadAll);
                Console.ReadKey();
                break;
                //case ActionEnum.Take:
                //    var allUsers = userService.ReadAll();
                //    WriteAll<User>(allUsers);
                //    var readUserId = ReadId();
                //    List<User> listUser = new List<User>();
                //    foreach ( int id in readUserId)
                //    {
                //        listUser.Add(userService.Read(id));
                //    }

                //    var materialTake = Read<Material>();
                //    materialTake = materialService.Take(materialTake, listUser) ;
                //    Write(materialTake);
                //    Console.ReadKey();
                //    break;
            }
        }
Example #2
0
        public async Task <IActionResult> Create(MaterialInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model ?? new MaterialInputModel()));
            }

            await service.Create(model);

            return(this.Redirect("/Material/ViewAll"));
        }
        public ActionResult CreateMaterial([Bind(Include = "Name,Cost")] MaterialModel material)
        {
            if (ModelState.IsValid)
            {
                _materialService.Create(material.Name, material.Cost);
                return(RedirectToAction("Index"));
            }


            return(View(material));
        }
Example #4
0
        public async Task <IActionResult> Create([FromBody] MaterialCreate request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var resultId = await _materialService.Create(request);

            if (!resultId.IsSuccessed)
            {
                return(BadRequest(resultId));
            }

            var result = await _materialService.GetById(resultId.ResultObj);

            return(Ok(result));
        }
Example #5
0
 protected override void OnBtnCommand(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (e.Item.Caption == BtnCommandEnum.Save)
     {
         eRPM002MaterialBindingSource.EndEdit();
         var tempData = eRPM002MaterialBindingSource.DataSource as ERP_M002_Material;
         if (this.Tag.ToString() == BtnCommandEnum.Add)
         {
             materialService.Create(tempData);
         }
         else if (this.Tag.ToString() == BtnCommandEnum.Edit)
         {
             materialService.Update(tempData);
         }
         DialogResult = DialogResult.OK;
     }
     if (e.Item.Caption == BtnCommandEnum.Cancel)
     {
         DialogResult = DialogResult.Cancel;
     }
 }