示例#1
0
        public IActionResult TaskModified(int id)
        {
            var        salesVm  = _context.SalesMen.Find(id);
            vmSalesMan salesMan = new vmSalesMan();

            salesMan.Description = salesVm.Description;
            salesMan.TaskName    = salesVm.TaskName;
            // salesMan.ManagerId = salesVm.ManagerId;
            ViewBag.manager = new SelectList(_work.Managers.GetAll(), "Id", "Name");
            return(PartialView("_SalesTaskModified", salesMan));
        }
示例#2
0
        // GET: Salesman/Details/5

        // GET: Salesman/Create
        public IActionResult Create(vmSalesMan vmSales)
        {
            if (ModelState.IsValid)
            {
                SalesMan sales = new SalesMan()
                {
                    Name     = vmSales.Name,
                    Email    = vmSales.Email,
                    Address  = vmSales.Address,
                    Phone    = vmSales.Phone,
                    ClientId = vmSales.ClientId,
                    //  ManagerId = vmSales.ManagerId,
                    ProductId  = vmSales.ProductId,
                    SeheduleId = vmSales.SeheduleId,
                    IconClass  = vmSales.IconClass,
                    IconColor  = vmSales.IconColor,
                    DateTime   = vmSales.DateTime != null ? vmSales.DateTime : DateTime.Now,
                    Pass       = vmSales.Pass
                };

                if (vmSales.Image != null)
                {
                    var fileName = ContentDispositionHeaderValue.Parse(vmSales.Image.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty);
                    var path     = _imagePath.GetImagePath(fileName, "Sales", vmSales.Name.Replace(" ", string.Empty));

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        vmSales.Image.CopyTo(stream);
                    }
                    sales.Image = _imagePath.GetImagePathForDb(path);
                }
                _work.Sales.Add(sales);
                _work.Save();

                return(Json(true));
            }

            return(Json(false));
        }