public async Task <IActionResult> CreateMeasurmentUnit(MeasurmentUnit model)
        {
            if (ModelState.IsValid)
            {
                if (await _repository.MeasurmentUnitExistsAsync(model.Name))
                {
                    ModelState.AddModelError("UnitExists", _stringLocalizer["A measuring unit with that name exists"].ToString());
                }
                else
                {
                    model.LastModifiedByName = User.Identity.Name;
                    int result = await _repository.AddMeasurmentUnitAsync(model);

                    if (result < 1)
                    {
                        TempData["MeasurmentUnitMessage"] = _stringLocalizer["Nothing added"].ToString();
                    }
                    else
                    {
                        TempData["MeasurmentUnitMessage"] = _stringLocalizer["Measuring unit added successfully"].ToString();
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewBag.Title = _stringLocalizer["Create Measurment Unit"].ToString();
            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(MeasurmentUnit measurmentUnit)
        {
            if (ModelState.IsValid)
            {
                _db.Update(measurmentUnit);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(measurmentUnit));
        }
        public async Task <IActionResult> DeleteMeasurmentUnit(long id)
        {
            MeasurmentUnit model = await _repository.GetMeasurmentUnitAsync(id);

            if (model != null)
            {
                ViewBag.Title = _stringLocalizer["Delete Measurment unit"].ToString();
                return(View(model));
            }
            TempData["MeasurmentUnitMessage"] = _stringLocalizer["Missing measurment unit"].ToString();
            return(RedirectToAction(nameof(Index)));
        }
Beispiel #4
0
        public void AddMerchandise(int companyId, string merchandiseName, MeasurmentUnit me)
        {
            var         company = GetCompanyDetails(companyId);
            Merchandise merch   = _context.Merchandises.SingleOrDefault(m => m.Name.Equals(merchandiseName) && m.MesaurmentUnit == me);

            if (merch == null)
            {
                merch = new Merchandise
                {
                    Name           = merch.Name,
                    MesaurmentUnit = merch.MesaurmentUnit
                };
                _context.Merchandises.Add(merch);
            }
            company.CurrentStock.Add(new CurrentStock
            {
                MerchandiseId       = merch.Id,
                AmountOfMerchandise = 0
            });
            _context.SaveChanges();
        }
        public async Task <IActionResult> ChangeStatus(long id)
        {
            MeasurmentUnit model = await _repository.GetMeasurmentUnitAsync(id);

            if (model != null)
            {
                model.LastModifiedByName = User.Identity.Name;
                int result = await _repository.UpdateMeasurmentUnitAsync(model, true);

                if (result > 0)
                {
                    TempData["MeasurmentUnitMessage"] = _stringLocalizer["Measurment unit changed"].ToString();
                    return(RedirectToAction(nameof(Index)));
                }
                else if (result == 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            TempData["MeasurmentUnitMessage"] = _stringLocalizer["Missing measurment unit"].ToString();
            return(RedirectToAction(nameof(Index)));
        }
Beispiel #6
0
        public static string GetUnitHebrewValue(MeasurmentUnit unit)
        {
            switch (unit)
            {
            case MeasurmentUnit.HundredGrams:
                return(HebMeasurmentValue(HundredGrams));

            case MeasurmentUnit.Kilo:
                return(HebMeasurmentValue(Kilo));

            case MeasurmentUnit.Unit:
                return(HebMeasurmentValue(Unit));

            case MeasurmentUnit.Liter:
                return(HebMeasurmentValue(Liter));

            case MeasurmentUnit.Milliliter:
                return(HebMeasurmentValue(Milliliter));

            default:
                return(null);
            }
        }
 public Height(int size, MeasurmentUnit unit)
 {
     this.Size = size;
     this.Unit = unit;
 }
Beispiel #8
0
        public IActionResult AddMerchandise([Bind("CompanyId")] int companyId, [Bind("MerchandiseName")] string merchandiseName, [Bind("Unit")] MeasurmentUnit unit)
        {
            _companyRepository.AddMerchandise(companyId, merchandiseName, unit);

            return(RedirectToAction("Details", new { companyId }));
        }