Ejemplo n.º 1
0
 public void LoadUnits()
 {
     foreach (var kvp in UnitService.GetAll())
     {
         var unit     = kvp.Key;
         var position = kvp.Value;
         unit.AddToZone(this, position);
     }
 }
Ejemplo n.º 2
0
        public IHttpActionResult Get()
        {
            var completeUnit = UnitService.GetAll();

            if (completeUnit == null)
            {
                throw new NotFoundException(ErrorMessages.UnidadNoEncontrada);
            }

            var dto = Mapper.Map <List <UnitResponse> >(completeUnit);

            return(Ok(dto));
        }
Ejemplo n.º 3
0
 public ActionResult Create()
 {
     ViewBag.ListCategory     = BuildListCategory();
     ViewBag.ListBrand        = ProductBrandService.GetAll();
     ViewBag.ListCountry      = CountryService.GetAll();
     ViewBag.ListStore        = ProductStoreService.GetAll();
     ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
     ViewBag.ListUnit         = UnitService.GetAll();
     ViewBag.ListColor        = BuildListColor();
     ViewBag.ListSize         = BuildListSize();
     ViewBag.ListHour         = DataHelper.ListHour;
     return(View("Create", new ProductModels()));
 }
Ejemplo n.º 4
0
        // GET: /<controller>/
        public IActionResult Index(Unit unit)
        {
            var         planService = new PlanService();
            var         json        = HttpContext.Request.Cookies["user"];
            User        loginuser   = JsonConvert.DeserializeObject <User>(json);
            List <Plan> plans       = null;
            List <Unit> units       = null;

            if (loginuser.relation.Eid == 1)
            {
                plans = planService.GetAll();
                if (unit.Proid > 0)
                {
                    units = unitService.QueryByProid((int)unit.Proid);
                }
                else if (unit.Pid > 0)
                {
                    units = unitService.QueryByPid((int)unit.Pid);
                }
                else if (unit.UnName == null)
                {
                    units = unitService.GetAll();
                }
                else
                {
                    units = unitService.Query(0, unit.UnName);
                }
            }
            else
            {
                int proid = (int)loginuser.relation.Proid;
                plans = planService.QueryByProid(proid);
                if (unit.Pid > 0)
                {
                    units = unitService.QueryByPid((int)unit.Pid);
                }
                else if (unit.UnName == null)
                {
                    units = unitService.QueryByProid(proid);
                }
                else
                {
                    units = unitService.Query(proid, unit.UnName);
                }
            }
            ViewData["units"] = units;
            ViewData["plans"] = plans;
            return(View());
        }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        buildingService = new BuildingService();
        unitService     = new UnitService();
        placedBuildings = new List <BuildingView>();

        WoodRessource  = 500;
        MetalRessource = 500;
        FoodRessource  = 500;

        RessourceInfo.text = DisplayRessources();

        buildings = buildingService.GetBuildable();
        units     = unitService.GetAll();

        InvokeRepeating("AddRessources", 1, 1);
    }
Ejemplo n.º 6
0
        public IActionResult Index(Thecase caselist)
        {
            var                 json      = HttpContext.Request.Cookies["user"];
            User                loginuser = JsonConvert.DeserializeObject <User>(json);
            List <Plan>         plans     = null;
            List <Unit>         units     = null;
            List <Project>      projects  = null;
            List <Userrelation> relations = null;
            List <Thecase>      cases     = null;

            if (loginuser.relation.Eid == 1)
            {
                plans     = planService.GetAll();
                projects  = projectService.GetAll();
                units     = unitService.GetAll();
                relations = relationService.GetAll();
                if (caselist.Proid > 0)
                {
                    cases = caseService.QueryByProid((int)caselist.Proid);
                }
                else if (caselist.Pid > 0)
                {
                    cases = caseService.QueryByPid((int)caselist.Pid);
                }
                else if (caselist.Unid > 0)
                {
                    cases = caseService.QueryByUnid((int)caselist.Unid);
                }
                else if (caselist.State != null)
                {
                    cases = caseService.QueryByState(caselist.State);
                }
                else if (caselist.Name != null)
                {
                    cases = caseService.QueryByName(loginuser.relation.Name);
                }
                else if (caselist.Toname != null)
                {
                    cases = caseService.QueryByToName(loginuser.relation.Name);
                }
                else if (caselist.State != null)
                {
                    cases = caseService.QueryByState(caselist.State);
                }
                else if (caselist.Ctitle == null)
                {
                    cases = caseService.GetAll();
                }
                else
                {
                    cases = caseService.Query(0, caselist);
                }
            }
            else
            {
                int proid = (int)loginuser.relation.Proid;
                projects  = projectService.QueryById(proid);
                plans     = planService.QueryByProid(proid);
                units     = unitService.QueryByProid(proid);
                relations = relationService.QueryByProid(proid);
                if (caselist.Pid > 0)
                {
                    cases = caseService.QueryByPid((int)caselist.Pid);
                }
                else if (caselist.Unid > 0)
                {
                    cases = caseService.QueryByUnid((int)caselist.Unid);
                }
                else if (caselist.State != null)
                {
                    cases = caseService.QueryByState(caselist.State);
                }
                else if (caselist.Name != null)
                {
                    cases = caseService.QueryByName(loginuser.relation.Name);
                }
                else if (caselist.Toname != null)
                {
                    cases = caseService.QueryByToName(loginuser.relation.Name);
                }
                else if (caselist.Ctitle == null)
                {
                    cases = caseService.QueryByProid(proid);
                }
                else
                {
                    cases = caseService.Query(proid, caselist);
                }
            }
            ViewData["projects"]  = projects;
            ViewData["plans"]     = plans;
            ViewData["units"]     = units;
            ViewData["relations"] = relations;
            ViewData["cases"]     = cases;
            return(View());
        }
Ejemplo n.º 7
0
        public ActionResult OnEdit(ProductModels product)
        {
            var productUpdate = ProductService.Find(product.Id);

            if (productUpdate != null)
            {
                if (string.IsNullOrWhiteSpace(product.Code))
                {
                    product.Code = $"MP-{DateTime.Now.Ticks.GetHashCode()}";
                }
                product.ImageUrl = product.Image != null?
                                   product.Image.Upload() :
                                       product.ImageUrl.ToImageOriginalPath();

                productUpdate.Name         = product.Name;
                productUpdate.Type         = product.CategoryId;
                productUpdate.Summary      = product.Summary;
                productUpdate.Code         = product.Code;
                productUpdate.Image        = product.ImageUrl;
                productUpdate.BrandId      = product.BrandId;
                productUpdate.Country      = product.Country;
                productUpdate.Store        = product.Store;
                productUpdate.Manufacturer = product.ManufacturerId;
                productUpdate.AccountId    = product.AccountId;
                productUpdate.Number       = product.Number;
                productUpdate.Unit1        = product.Unit;
                productUpdate.Weight       = product.Weight;
                productUpdate.Quantity     = product.Quantity;
                productUpdate.Npp          = Convert.ToDouble(product.Npp);
                productUpdate.Width        = product.Width;
                productUpdate.Height       = product.Height;
                productUpdate.Depth        = product.Depth;
                productUpdate.Detail       = product.Detail;
                productUpdate.WarrantyTime = product.WarrantyTime;
                productUpdate.ExpireDate   = product.ExpireDate;
                productUpdate.Title        = product.MetaTitle;
                productUpdate.Keyword      = product.MetaKeyword;
                productUpdate.Description  = product.MetaDescription;
                productUpdate.Price        = product.Price;
                productUpdate.Transport1   = product.Transport1;
                productUpdate.Transport2   = product.Transport2;
                var result = ProductService.Update(productUpdate);
                //Tao cac anh san pham
                if (product.ProductImages != null && product.ProductImages.Length > 0)
                {
                    ProductImageService.Insert(productUpdate.ID, product.Name, product.ProductImages);
                }
                //Tao cac gia tri thuoc tinh
                if (product.AttrLabel != null && product.AttrLabel.Length > 0)
                {
                    ProductAttributeService.Insert(productUpdate.ID, product.AttrLabel, product.AttrDesc);
                }
                //Tao saleOff
                if (!string.IsNullOrWhiteSpace(product.Percent))
                {
                    ProductSaleOffService.Insert(new ProductSaleOff
                    {
                        ProductID = productUpdate.ID,
                        Percent   = Convert.ToDouble(product.Percent),
                        StartTime = Convert.ToDateTime(product.StartDate),
                        EndTime   = Convert.ToDateTime(product.EndDate)
                    });
                }
                //Tao kich co
                if (product.Size != null && product.Size.Length > 0)
                {
                    ProductSizeService.Insert(productUpdate.ID, product.Size);
                }
                //Tao mau sac
                if (product.Color != null && product.Color.Length > 0)
                {
                    ProductColorService.Insert(productUpdate.ID, product.Color);
                }

                SetFlashMessage(result == Result.Ok?
                                $"Cập nhật sản phẩm '{product.Name}' thành công.":
                                "Lỗi khi cập nhật sản phẩm '{product.Name}'"
                                );
                if (product.SaveList)
                {
                    return(RedirectToAction("Index"));
                }
                ViewBag.ListCategory     = BuildListCategory();
                ViewBag.ListBrand        = ProductBrandService.GetAll();
                ViewBag.ListCountry      = CountryService.GetAll();
                ViewBag.ListStore        = ProductStoreService.GetAll();
                ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
                ViewBag.ListUnit         = UnitService.GetAll();
                ViewBag.ListColor        = BuildListColor(product.Color);
                ViewBag.ListSize         = BuildListSize(product.Size);
                ViewBag.ListHour         = DataHelper.ListHour;
                return(View("Edit", product));
            }
            ViewBag.ListBrand        = ProductBrandService.GetAll();
            ViewBag.ListCountry      = CountryService.GetAll();
            ViewBag.ListStore        = ProductStoreService.GetAll();
            ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
            ViewBag.ListUnit         = UnitService.GetAll();
            ViewBag.ListColor        = BuildListColor(product.Color);
            ViewBag.ListSize         = BuildListSize(product.Size);
            ViewBag.ListHour         = DataHelper.ListHour;
            return(View("Edit", product));
        }
Ejemplo n.º 8
0
        public ActionResult Edit(int id)
        {
            var product = ProductService.FindToModify(id);

            if (product == null)
            {
                return(RedirectToAction("Index"));
            }
            var modelEdit = new ProductModels
            {
                Id                   = product.ID,
                Name                 = product.Name,
                ImageUrl             = product.Image,
                CategoryId           = product.Type ?? 0,
                Code                 = product.Code,
                BrandId              = product.BrandId,
                Store                = product.Store,
                Country              = product.Country,
                ManufacturerId       = product.Manufacturer,
                AccountId            = product.AccountId,
                Number               = product.Number ?? 0,
                Unit                 = product.Unit1,
                Quantity             = product.Quantity,
                Weight               = product.Weight,
                Npp                  = product.Npp?.ToString() ?? "",
                Width                = product.Width,
                Height               = product.Height,
                Depth                = product.Depth,
                Summary              = product.Summary,
                Detail               = product.Detail,
                WarrantyTime         = product.WarrantyTime,
                ExpireDate           = product.ExpireDate,
                Transport1           = product.Transport1 ?? 0,
                Transport2           = product.Transport2 ?? 0,
                MetaTitle            = product.Title,
                MetaDescription      = product.Description,
                MetaKeyword          = product.Keyword,
                Price                = (int)(product.Price ?? 0),
                ListProductImages    = product.ProductImages?.ToList() ?? new List <ProductImage>(),
                ListProductAttribute = product.ProductAttribute?.ToList() ?? new List <ProductAttribute>(),
            };

            if (product.ProductSaleOff != null && product.ProductSaleOff.Count > 0)
            {
                var saleOffItem = product.ProductSaleOff.FirstOrDefault();
                modelEdit.Percent   = saleOffItem.Percent?.ToString() ?? "";
                modelEdit.StartDate = saleOffItem.StartTime?.ToString() ?? "";
                modelEdit.EndDate   = saleOffItem.EndTime?.ToString() ?? "";
            }

            ViewBag.ListCategory     = BuildListCategory();
            ViewBag.ListBrand        = ProductBrandService.GetAll();
            ViewBag.ListCountry      = CountryService.GetAll();
            ViewBag.ListStore        = ProductStoreService.GetAll();
            ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
            ViewBag.ListUnit         = UnitService.GetAll();
            ViewBag.ListColor        = BuildListColor(
                product.ProductColor?.Select(item => item.ColorCode).ToArray());
            ViewBag.ListSize =
                BuildListSize(product.ProductSize?.Select(item => item.Size).ToArray());
            ViewBag.ListHour = DataHelper.ListHour;

            return(View("Edit", modelEdit));
        }
Ejemplo n.º 9
0
        public ActionResult OnCreate(ProductModels product)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrWhiteSpace(product.Code))
                {
                    product.Code = string.Format("{0}-{1}", ConfigHelper.ProductCode, DateTime.Now.Ticks.GetHashCode());
                }
                product.ImageUrl = product.Image != null?
                                   product.Image.Upload() :
                                       product.ImageUrl;

                var newProduct = new Product
                {
                    Name         = product.Name,
                    Type         = product.CategoryId,
                    Summary      = product.Summary,
                    Code         = product.Code,
                    Image        = product.ImageUrl,
                    BrandId      = product.BrandId,
                    Country      = product.Country,
                    Store        = product.Store,
                    Manufacturer = product.ManufacturerId,
                    AccountId    = 0,
                    Number       = product.Number,
                    Unit1        = product.Unit,
                    Weight       = product.Weight,
                    Quantity     = product.Quantity,
                    Npp          = Convert.ToDouble(product.Npp),
                    Width        = product.Width,
                    Height       = product.Height,
                    Depth        = product.Depth,
                    Detail       = product.Detail,
                    WarrantyTime = product.WarrantyTime,
                    ExpireDate   = product.ExpireDate,
                    Title        = product.MetaTitle,
                    Keyword      = product.MetaKeyword,
                    Description  = product.MetaDescription,
                    Price        = product.Price,
                    Transport1   = product.Transport1,
                    Transport2   = product.Transport2,
                    Status       = false
                };
                var result = ProductService.Insert(newProduct);

                //Tao cac anh Slide va properties
                if (product.ProductImages != null && product.ProductImages.Length > 0)
                {
                    ProductImageService.Insert(newProduct.ID, product.Name, product.ProductImages);
                }
                //Tao cac gia tri thuoc tinh
                if (product.AttrLabel != null && product.AttrLabel.Length > 0)
                {
                    ProductAttributeService.Insert(newProduct.ID, product.AttrLabel, product.AttrDesc);
                }
                //Tao saleOff
                if (!string.IsNullOrWhiteSpace(product.Percent))
                {
                    ProductSaleOffService.Insert(new ProductSaleOff
                    {
                        ProductID = newProduct.ID,
                        Percent   = Convert.ToDouble(product.Percent),
                        StartTime = Convert.ToDateTime(product.StartDate),
                        EndTime   = Convert.ToDateTime(product.EndDate)
                    });
                }
                //Tao kich co
                if (product.Size != null && product.Size.Length > 0)
                {
                    ProductSizeService.Insert(newProduct.ID, product.Size);
                }
                //Tao mau sac
                if (product.Color != null && product.Color.Length > 0)
                {
                    ProductColorService.Insert(newProduct.ID, product.Color);
                }
                SetFlashMessage(result == Result.Ok?
                                $"Thêm sản phẩm '{product.Name}' thành công.":
                                "Lỗi khi thêm mới sản phẩm");
                if (product.SaveList)
                {
                    return(RedirectToAction("Index"));
                }
                ViewBag.ListCategory     = BuildListCategory();
                ViewBag.ListBrand        = ProductBrandService.GetAll();
                ViewBag.ListCountry      = CountryService.GetAll();
                ViewBag.ListStore        = ProductStoreService.GetAll();
                ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
                ViewBag.ListUnit         = UnitService.GetAll();
                ViewBag.ListColor        = BuildListColor(product.Color);
                ViewBag.ListSize         = BuildListSize(product.Size);
                ViewBag.ListHour         = DataHelper.ListHour;
                ModelState.Clear();
                return(View("Create", product.ResetValue()));
            }
            ViewBag.ListCategory     = BuildListCategory();
            ViewBag.ListBrand        = ProductBrandService.GetAll();
            ViewBag.ListCountry      = CountryService.GetAll();
            ViewBag.ListStore        = ProductStoreService.GetAll();
            ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
            ViewBag.ListUnit         = UnitService.GetAll();
            ViewBag.ListColor        = BuildListColor(product.Color);
            ViewBag.ListSize         = BuildListSize(product.Size);
            ViewBag.ListHour         = DataHelper.ListHour;

            return(View("Create", product));
        }
Ejemplo n.º 10
0
 // GET: Units
 public ActionResult Index()
 {
     return(View(db.GetAll()));
 }
Ejemplo n.º 11
0
        public ActionResult Units()
        {
            var units = service.GetAll();

            return(Json(units, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
 public ActionResult Index()
 {
     return(View("Index", UnitService.GetAll()));
 }