Exemplo n.º 1
0
        public async Task <IActionResult> CreateItem([FromBody] PriceListItemDTO model)
        {
            if (ModelState.IsValid)
            {
                var user = await AvioAdminService.GetCurrentUser();

                if (user != null)
                {
                    var avioCompany = await AvioService.GetCompany(user.AvioCompanyId);

                    if (avioCompany != null)
                    {
                        PriceListItem item = new PriceListItem()
                        {
                            Name  = model.Name,
                            Price = model.Price
                        };

                        avioCompany.PriceList.Add(item);
                        await AvioService.UpdateCompany(avioCompany);

                        return(Ok(200));
                    }

                    return(BadRequest("Company wasn't found."));
                }

                return(Unauthorized("You must log in as an administrator of this company."));
            }

            return(BadRequest("Not enough data provided."));
        }
Exemplo n.º 2
0
        public ActionResult Edit(PriceListItem item)
        {
            if (ModelState.IsValid)
            {
                var data = Mapper.Map <PriceListDto>(item);

                data.ModifiedDate = DateTime.Now;
                data.ModifiedBy   = CurrentUser.USERNAME;

                try
                {
                    _priceListBLL.Save(data, CurrentUser);
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                }
                return(RedirectToAction("Index", "MstPriceList"));
            }
            item.MainMenu     = _mainMenu;
            item.CurrentLogin = CurrentUser;
            item = listdata(item);
            var VendorList = _vendorBLL.GetVendor();

            item.VendorList  = new SelectList(VendorList, "MstVendorId", "VendorName");
            item.ChangesLogs = GetChangesHistory((int)Enums.MenuList.MasterPriceList, item.MstPriceListId);
            return(View(item));
        }
Exemplo n.º 3
0
        public IHttpActionResult PutPriceListItem(int id, PriceListItem priceListItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != priceListItem.Id)
            {
                return(BadRequest());
            }

            db.Entry(priceListItem).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PriceListItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetPriceListItem(int id)
        {
            PriceListItem priceListItem = db.PriceListItems.Find(id);

            if (priceListItem == null)
            {
                return(NotFound());
            }

            return(Ok(priceListItem));
        }
Exemplo n.º 5
0
        public PriceListItem listdata(PriceListItem model)
        {
            var listvehicleType = _settingBLL.GetSetting().Select(x => new { x.SettingGroup, x.SettingName, x.SettingValue }).ToList().Where(x => x.SettingGroup == "VEHICLE_TYPE").Distinct().OrderBy(x => x.SettingValue);

            model.VehicleTypeList = new SelectList(listvehicleType, "SettingName", "SettingValue");

            var listvehicleUsage = _settingBLL.GetSetting().Select(x => new { x.SettingGroup, x.SettingName, x.SettingValue }).ToList().Where(x => x.SettingGroup == "VEHICLE_USAGE_BENEFIT").Distinct().OrderBy(x => x.SettingValue);

            model.VehicleUsageList = new SelectList(listvehicleUsage, "SettingName", "SettingValue");
            return(model);
        }
Exemplo n.º 6
0
        public IHttpActionResult PostPriceListItem(PriceListItem priceListItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PriceListItems.Add(priceListItem);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = priceListItem.Id }, priceListItem));
        }
Exemplo n.º 7
0
        public JsonResult UploadFile(HttpPostedFileBase upload)
        {
            var qtyPacked = string.Empty;
            var qty       = string.Empty;

            var data  = (new ExcelReader()).ReadExcel(upload);
            var model = new List <PriceListItem>();

            if (data != null)
            {
                foreach (var dataRow in data.DataRows)
                {
                    if (dataRow[0] == "")
                    {
                        continue;
                    }
                    var item = new PriceListItem();
                    try
                    {
                        string VendorName     = dataRow[0].ToString();
                        string Status         = dataRow[14].ToString();
                        string InstallmentHMS = dataRow[8].ToString();
                        InstallmentHMS = InstallmentHMS.Trim(',');
                        decimal InstallmentHMSDec = decimal.Parse(String.IsNullOrEmpty(InstallmentHMS)? "0" : InstallmentHMS);
                        string  InstallmentEMP    = dataRow[9].ToString();
                        InstallmentEMP = InstallmentEMP.Trim(',');
                        decimal   InstallmentEMPDec = decimal.Parse(String.IsNullOrEmpty(InstallmentEMP) ? "0" : InstallmentEMP);
                        VendorDto vendor            = _vendorBLL.GetExist(VendorName);

                        item.Vendor        = vendor == null? 0 : vendor.MstVendorId;
                        item.VendorName    = vendor == null? "Not Registered" : VendorName;
                        item.VehicleType   = dataRow[1].ToString();
                        item.VehicleUsage  = dataRow[2].ToString();
                        item.ZonePriceList = dataRow[3].ToString();
                        item.Manufacture   = dataRow[4].ToString();
                        item.Model         = dataRow[5].ToString();
                        item.Series        = dataRow[6].ToString();
                        item.Year          = Int32.Parse(dataRow[7].ToString());
                        item.InstallmenHMS = Math.Round(InstallmentHMSDec);
                        item.InstallmenEMP = Math.Round(InstallmentEMPDec);
                        item.IsActive      = Status.Equals("Active") ? true : false;
                        item.IsActiveS     = Status;
                        item.ErrorMessage  = "";
                        model.Add(item);
                    }
                    catch (Exception ex)
                    {
                        item.ErrorMessage = ex.Message;
                    }
                }
            }
            return(Json(model));
        }
        public Task <Guid> Handle(CreatePriceListItemCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = PriceListItem.Create(
                command.CountryCode,
                SubscriptionPeriod.Of(command.SubscriptionPeriodCode),
                PriceListItemCategory.Of(command.CategoryCode),
                MoneyValue.Of(command.PriceValue, command.PriceCurrency));

            _aggregateStore.AppendChanges(priceListItem);

            return(Task.FromResult(priceListItem.Id));
        }
Exemplo n.º 9
0
        public void CreatePriceListItem_IsSuccessful()
        {
            // Act
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            // Assert
            var priceListItemCreated = AssertPublishedDomainEvent <PriceListItemCreatedDomainEvent>(priceListItem);

            Assert.That(priceListItemCreated.PriceListItemId, Is.EqualTo(priceListItem.Id));
        }
Exemplo n.º 10
0
        public IHttpActionResult DeletePriceListItem(int id)
        {
            PriceListItem priceListItem = db.PriceListItems.Find(id);

            if (priceListItem == null)
            {
                return(NotFound());
            }

            db.PriceListItems.Remove(priceListItem);
            db.SaveChanges();

            return(Ok(priceListItem));
        }
Exemplo n.º 11
0
        //[Authorize(Roles = "AppUser")]
        public IHttpActionResult PriceListItemId()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var httpRequest = HttpContext.Current.Request;
            var newPriceListItemReservationModel = new PriceListItemReservationModel();

            try
            {
                newPriceListItemReservationModel = JsonConvert.DeserializeObject <PriceListItemReservationModel>(httpRequest.Form[0]);
            }
            catch (JsonSerializationException)
            {
                return(BadRequest(ModelState));
            }

            PriceListItem pi = db.PriceListItems
                               .Where(b => b.VehicleId == newPriceListItemReservationModel.VehicleId)
                               .FirstOrDefault();

            pi.PriceListId     = newPriceListItemReservationModel.PriceListId;
            pi.PriceList       = db.PriceLists.Find(newPriceListItemReservationModel.PriceListId);
            db.Entry(pi).State = EntityState.Modified;

            Vehicle v = db.Vehicles
                        .Where(b => b.Id == newPriceListItemReservationModel.VehicleId)
                        .FirstOrDefault();

            v.Available       = false;
            db.Entry(v).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException)
            {
                return(BadRequest(ModelState));
            }
            catch (DbUpdateException)
            {
                return(BadRequest(ModelState));
            }

            return(Ok("Success"));
        }
Exemplo n.º 12
0
        public void ActivatePriceListItem_WhenItemIsActive_ThenActivationIgnored()
        {
            // Arrange
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            // Act
            priceListItem.Activate();

            // Assert
            AssertDomainEventNotPublished <PriceListItemActivatedDomainEvent>(priceListItem);
        }
Exemplo n.º 13
0
        public ActionResult Create()
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer)
            {
                return(RedirectToAction("Index"));
            }
            var model = new PriceListItem();

            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model = listdata(model);
            var VendorList = _vendorBLL.GetVendor();

            model.VendorList = new SelectList(VendorList, "MstVendorId", "VendorName");

            return(View(model));
        }
Exemplo n.º 14
0
        public void DeactivatePriceListItem_WhenItemNotActive_ThenDeactivationIgnored()
        {
            // Arrange
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            priceListItem.Deactivate();

            // Act
            priceListItem.Deactivate();

            // Assert
            var priceListItemActivatedEvents = AssertPublishedDomainEvents <PriceListItemDeactivatedDomainEvent>(priceListItem);

            Assert.That(priceListItemActivatedEvents.Count, Is.EqualTo(1));
        }
Exemplo n.º 15
0
        public void ChangePriceListItem_IsSuccessful()
        {
            // Arrange
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            // Act
            priceListItem.ChangeAttributes(
                "ARG",
                SubscriptionPeriod.HalfYear,
                PriceListItemCategory.Renewal,
                MoneyValue.Of(25, "ARS"));

            // Assert
            var priceListItemAttributesChangedEvent = AssertPublishedDomainEvent <PriceListItemAttributesChangedDomainEvent>(priceListItem);

            Assert.That(priceListItemAttributesChangedEvent.PriceListItemId, Is.EqualTo(priceListItem.Id));
        }
Exemplo n.º 16
0
        public ActionResult View(int?MstPriceListid)
        {
            if (!MstPriceListid.HasValue)
            {
                return(HttpNotFound());
            }
            var data  = _priceListBLL.GetByID(MstPriceListid.Value);
            var model = new PriceListItem();

            model              = Mapper.Map <PriceListItem>(data);
            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model              = listdata(model);

            var VendorList = _vendorBLL.GetVendor();

            model.VendorList  = new SelectList(VendorList, "MstVendorId", "VendorName");
            model.ChangesLogs = GetChangesHistory((int)Enums.MenuList.MasterPriceList, MstPriceListid.Value);

            return(View(model));
        }
Exemplo n.º 17
0
        private void UpdatePriceListItems(IEnumerable <Good> goods)
        {
            NewPriceListItems = new ObservableCollection <PriceListItem>();

            foreach (Good good in goods)
            {
                PriceListItem newPriceListItem = new PriceListItem()
                {
                    Good        = good,
                    GoodId      = good.Id,
                    PriceListId = Entity.Id,
                };

                PriceListItems.Add(newPriceListItem);

                if (ActionType == ActionType.Edit)
                {
                    NewPriceListItems.Add(newPriceListItem);
                }
            }
        }
Exemplo n.º 18
0
 public async Task AddPriceListItem(PriceListItem p)
 {
     _context.PriceListItems.Add(p);
     await _context.SaveChangesAsync();
 }
Exemplo n.º 19
0
        public ActionResult Create(PriceListItem item)
        {
            //if (ModelState.IsValid)
            //{
            FMSEntities entities = new FMSEntities();

            //String message = "";
            bool valid = true;

            var    vehicleSpect     = entities.MST_VEHICLE_SPECT.Where(x => (x.YEAR == item.Year) && (x.MANUFACTURER == item.Manufacture) && (x.MODEL == item.Model) && (x.SERIES == item.Series)).ToList();
            var    vendor           = entities.MST_VENDOR.Where(X => (X.SHORT_NAME == item.Vendor + "")).ToList();
            var    vehicleType      = entities.MST_SETTING.Where(x => (x.SETTING_GROUP == "VEHICLE_TYPE") && (x.SETTING_VALUE == item.VehicleType)).ToList();
            string vehicleUsageText = "";

            if (item.VehicleType.Equals("WTC"))
            {
                vehicleUsageText = "VEHICLE_USAGE_BENEFIT";
            }
            else if (item.VehicleType.Equals("Benefit"))
            {
                vehicleUsageText = "VEHICLE_USAGE_WTC";
            }

            var vehicleUsage = entities.MST_SETTING.Where(x => (x.SETTING_GROUP == vehicleUsageText) && (x.SETTING_VALUE == item.VehicleUsage)).ToList();

            if (vehicleSpect.Count == 0)
            {
                valid = false;
                ViewData["message"] = "Data not exists in vehicle spect";
            }
            else if (vendor.Count == 0)
            {
                valid = false;
                ViewData["message"] = "Data not exists in vendor";
            }
            else if (vehicleType.Count == 0)
            {
                valid = false;
                ViewData["message"] = "Data not exists in vehicle type";
            }
            else if (vehicleUsage.Count == 0)
            {
                valid = false;
                ViewData["message"] = "Data not exists in vehicle usage";
            }
            else
            {
                valid = true;
            }

            if (valid)
            {
                //var data = Mapper.Map<PriceListDto>(item);
                //data.CreatedBy = CurrentUser.USERNAME;
                //data.CreatedDate = DateTime.Today;
                //data.ModifiedDate = null;
                //try
                //{
                //    _priceListBLL.Save(data);
                //}
                //catch (Exception ex)
                //{
                //    var msg = ex.Message;
                //}

                return(RedirectToAction("Index", "MstPriceList"));
            }
            else
            {
                var model = new PriceListItem();
                model.MainMenu     = _mainMenu;
                model.CurrentLogin = CurrentUser;
                model = listdata(model);
                var VendorList = _vendorBLL.GetVendor();
                model.VendorList = new SelectList(VendorList, "MstVendorId", "VendorName");
                return(View(model));
            }
            //}
        }
Exemplo n.º 20
0
    protected void lnkSavePriceListValue_OnClick(object sender, EventArgs e)
    {
        var lstInsertPriceList = new List <PriceListValue>();
        var lstUpdatePriceList = new List <PriceListValue>();
        var lstDeletePriceList = new List <PriceListValue>();

        foreach (RepeaterItem item in rptProduct.Items)
        {
            var lblProductId = item.FindControl("lblProductId") as Label;
            var rptPriceList = item.FindControl("rptPriceList") as Repeater;

            foreach (RepeaterItem PriceListItem in rptPriceList.Items)
            {
                var lblPriceListId      = PriceListItem.FindControl("lblPriceListId") as Label;
                var lblPriceListValueId = PriceListItem.FindControl("lblPriceListValueId") as Label;
                var txtProductPrice     = PriceListItem.FindControl("txtProductPrice") as TextBox;

                if (txtProductPrice.zToInt() > 0)
                {
                    #region Set Value

                    var objPriceListValue = new PriceListValue()
                    {
                        PriceListValueId = lblPriceListValueId.zToInt(),
                        ProductId        = lblProductId.zToInt(),
                        PriceListId      = lblPriceListId.zToInt(),
                        Price            = txtProductPrice.zToInt()
                    };

                    if (objPriceListValue.PriceListValueId.HasValue && objPriceListValue.PriceListValueId > 0)
                    {
                        lstUpdatePriceList.Add(objPriceListValue);
                        if (lstUpdatePriceList.Count >= 500)
                        {
                            lstUpdatePriceList.Update();
                            lstUpdatePriceList = new List <PriceListValue>();
                        }
                    }
                    else
                    {
                        lstInsertPriceList.Add(objPriceListValue);
                        if (lstInsertPriceList.Count >= 500)
                        {
                            lstInsertPriceList.Insert();
                            lstInsertPriceList = new List <PriceListValue>();
                        }
                    }

                    #endregion
                }
                else if (lblPriceListValueId.zToInt() > 0)
                {
                    #region Delete

                    lstDeletePriceList.Add(new PriceListValue()
                    {
                        PriceListValueId = lblPriceListValueId.zToInt()
                    });
                    if (lstDeletePriceList.Count >= 500)
                    {
                        lstDeletePriceList.Delete();
                        lstDeletePriceList = new List <PriceListValue>();
                    }

                    #endregion
                }
            }
        }

        lstUpdatePriceList.Update();
        lstInsertPriceList.Insert();
        lstDeletePriceList.Delete();

        LoadPriceListValue();
        CU.ZMessage(eMsgType.Success, string.Empty, "Price List Saved Successfully");
    }
Exemplo n.º 21
0
 public async Task RemovePriceListItem(PriceListItem p)
 {
     _context.PriceListItems.Remove(p);
     await _context.SaveChangesAsync();
 }
 public async Task RemovePriceListItem(PriceListItem p)
 {
     await _repository.RemovePriceListItem(p);
 }
 public async Task AddPriceListItem(PriceListItem p)
 {
     await _repository.AddPriceListItem(p);
 }
Exemplo n.º 24
0
        public IHttpActionResult ChangeVehiclePrice()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var           httpRequest         = HttpContext.Current.Request;
            PriceListItem newPriceListItem    = new PriceListItem();
            PriceListItem changePriceListItem = null;

            try
            {
                newPriceListItem = JsonConvert.DeserializeObject <PriceListItem>(httpRequest.Form[0]);
            }
            catch (JsonSerializationException)
            {
                return(BadRequest(ModelState));
            }

            foreach (PriceListItem pi in db.PriceListItems)
            {
                if (pi.VehicleId == newPriceListItem.VehicleId)
                {
                    changePriceListItem = pi;
                    break;
                }
            }

            if (changePriceListItem != null)
            {
                try
                {
                    changePriceListItem.Price = newPriceListItem.Price;
                }
                catch (JsonSerializationException)
                {
                    return(BadRequest(ModelState));
                }

                try
                {
                    db.Entry(changePriceListItem).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (DbEntityValidationException)
                {
                    return(BadRequest(ModelState));
                }
                catch (DbUpdateException)
                {
                    return(BadRequest(ModelState));
                }
            }
            else
            {
                try
                {
                    newPriceListItem.Vehicle = db.Vehicles.Find(newPriceListItem.VehicleId);
                }
                catch (JsonSerializationException)
                {
                    return(BadRequest(ModelState));
                }

                db.PriceListItems.Add(newPriceListItem);

                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException)
                {
                    return(BadRequest(ModelState));
                }
                catch (DbUpdateException)
                {
                    return(BadRequest(ModelState));
                }
            }

            return(Ok("Success"));
        }