public List<VendorModel> Get(int psid)
        {
            VendorModel m1 = new VendorModel()
            {
                BN = "Test BN",
                BNId = 1,
                Buy = 20,
                Comments = "Test",
                Cost = 25,
                DeliveryCost = 3,
                GUID = "---",
                Id = 444,
                Marga = 37,
                Marga_Percent = 45,
                RasxodKredit = 12,
                SrokKredit = 12,
                VendorName = "Рога & Копыта"

            };

            VendorModel m2 = new VendorModel()
            {
                BN = "Test BN 2",
                BNId = 2,
                Buy = 20,
                Comments = "Test",
                Cost = 25,
                DeliveryCost = 3,
                GUID = "---",
                Id = 555,
                Marga = 37,
                Marga_Percent = 45,
                RasxodKredit = 12,
                SrokKredit = 12,
                VendorName = "Рога & Копыта 2"

            };

            List<VendorModel> vendors = new List<VendorModel>() { m1, m2 };
            return vendors;
            //throw new NotImplementedException();
        }
Example #2
0
        protected void PrepareVendorModel(VendorModel model, Vendor vendor, bool excludeProperties)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (vendor != null)
            {
                model.Id = vendor.Id;
                model.AssociatedCustomerEmails = _customerService
                                                 .GetAllCustomers(vendorId: vendor.Id)
                                                 .Select(c => c.Email)
                                                 .ToList();
                if (!excludeProperties)
                {
                    model.Name         = vendor.Name;
                    model.Email        = vendor.Email;
                    model.Description  = vendor.Description;
                    model.AdminComment = vendor.AdminComment;
                    model.Active       = vendor.Active;
                }
            }
        }
        protected override async void Seed()
        {
            _vendor = new VendorModel()
            {
                FirstName      = "test",
                LastName       = "vendor",
                CommissionRate = 0,
                PaymentDue     = 0
            };

            StringBuilder sqlBuilder = new StringBuilder();

            sqlBuilder.Append("insert into Vendors (FirstName, LastName, CommissionRate, PaymentDue) ");
            sqlBuilder.Append("values (@FirstName, @LastName, @CommissionRate, @PaymentDue); ");

            _vendor.Id = await _config.Connection.ExecuteRawSQL <dynamic>(sqlBuilder.ToString(), _vendor);

            var item = new ItemModel()
            {
                Name               = "Test Item",
                Description        = "Test Description",
                Price              = 1.00m,
                Sold               = false,
                PaymentDistributed = false,
                OwnerId            = _vendor.Id,
                Owner              = _vendor,
            };

            StringBuilder sql = new StringBuilder();

            sql.Append("insert into Items (Name, Description, Price, Sold, OwnerId, PaymentDistributed) ");
            sql.Append("values (@Name, @Description, @Price, @Sold, @OwnerId, @PaymentDistributed); ");


            var sqlResult = await _config.Connection.ExecuteRawSQL <dynamic>(sql.ToString(), item);
        }
        public virtual async Task <VendorModel> PrepareVendorModel()
        {
            var model = new VendorModel();

            //discounts
            await PrepareDiscountModel(model, null, true);

            //default values
            model.PageSize = 6;
            model.Active   = true;
            model.AllowCustomersToSelectPageSize = true;
            model.PageSizeOptions = _vendorSettings.DefaultVendorPageSizeOptions;

            //default value
            model.Active = true;

            //stores
            await PrepareStore(model);

            //prepare address model
            await PrepareVendorAddressModel(model, null);

            return(model);
        }
        public ActionResult Create(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var vendor = model.ToEntity();
                _vendorService.InsertVendor(vendor);
                //search engine name
                model.SeName = vendor.ValidateSeName(model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);
                //locales
                UpdateLocales(vendor, model);

                SuccessNotification(_localizationService.GetResource("Admin.Vendors.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = vendor.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #6
0
        //create
        public virtual ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }


            var model = new VendorModel();

            PrepareVendorModel(model, null, false, true);
            //locales
            AddLocales(_languageService, model.Locales);
            //default values
            model.PageSize = 6;
            model.Active   = true;
            model.AllowCustomersToSelectPageSize = true;
            model.PageSizeOptions = _vendorSettings.DefaultVendorPageSizeOptions;
            //Stores
            PrepareStoresModel(model);
            //default value
            model.Active = true;
            return(View(model));
        }
Example #7
0
 public ActionResult Edit(int id, VendorModel vendorModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _vendorService.UpdateVendor(vendorModel);
             TempData["Message"]     = "Vendor updated successfully.";
             TempData["MessageType"] = (int)AlertMessageTypes.Success;
             return(RedirectToAction("List"));
         }
         else
         {
             return(View(_vendorService));
         }
     }
     catch (Exception e)
     {
         _logger.Error(e);
         TempData["Message"]     = "Internal server error. Vendor not updated. Please contact administrator.";
         TempData["MessageType"] = (int)AlertMessageTypes.Danger;
         return(View(_vendorService));
     }
 }
Example #8
0
        public ActionResult List(GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            var vendors   = _vendorService.GetAllVendors(command.Page - 1, command.PageSize, true);
            var gridModel = new GridModel <VendorModel>
            {
                Data = vendors.Select(x =>
                {
                    var m = new VendorModel();
                    PrepareVendorModel(m, x, false);
                    return(m);
                }),
                Total = vendors.TotalCount,
            };

            return(new JsonResult
            {
                Data = gridModel
            });
        }
Example #9
0
        public ActionResult CreateVendor(VendorModel model)
        {
            if (ModelState.IsValid)
            {
                var newVendor = new Vendor
                {
                    Name           = model.Name,
                    Address        = model.Address,
                    City           = model.City,
                    State          = model.State,
                    ZipCode        = model.ZipCode,
                    Phone          = model.Phone,
                    PointOfContact = model.PointOfContact
                };

                context.Vendors.Add(newVendor);
                context.SaveChanges();

                TempData["CreateSuccess"] = model.Name + " was created successfully";
                return(RedirectToAction("ViewVendors"));
            }

            return(View(model));
        }
Example #10
0
        private List <IOffer> ParseOffers(
            IElement parent,
            List <Category> categories,
            List <Currency> currencies,
            int localDeliveryCost)
        {
            List <IOffer> offers = new List <IOffer>();
            IOffer        offer;

            foreach (var off in parent.QuerySelectorAll("offer"))
            {
                switch (off.GetAttribute("type"))
                {
                case "vendor.model":
                    offer = new VendorModel();
                    (offer as VendorModel).TypePrefix           = off.QuerySelector("typePrefix").TextContent;
                    (offer as VendorModel).Vendor               = off.QuerySelector("vendor").TextContent;
                    (offer as VendorModel).VendorCode           = off.QuerySelector("vendorCode").TextContent;
                    (offer as VendorModel).Model                = off.QuerySelector("model").TextContent;
                    (offer as VendorModel).ManufacturerWarranty = bool.Parse(off.QuerySelector("manufacturer_warranty").TextContent);
                    (offer as VendorModel).CountryOfOrigin      = off.QuerySelector("country_of_origin").TextContent;
                    break;

                case "book":
                    offer = new Book();
                    (offer as Book).Author            = off.QuerySelector("author").TextContent;
                    (offer as Book).Name              = off.QuerySelector("name").TextContent;
                    (offer as Book).Publisher         = off.QuerySelector("publisher").TextContent;
                    (offer as Book).Series            = off.QuerySelector("series").TextContent;
                    (offer as Book).Year              = Int32.Parse(off.QuerySelector("year").TextContent);
                    (offer as Book).ISBN              = off.QuerySelector("ISBN").TextContent;
                    (offer as Book).Volume            = Int32.Parse(off.QuerySelector("volume").TextContent);
                    (offer as Book).Part              = Int32.Parse(off.QuerySelector("part").TextContent);
                    (offer as Book).Language          = off.QuerySelector("language").TextContent;
                    (offer as Book).Binding           = off.QuerySelector("binding").TextContent;
                    (offer as Book).PageExtent        = Int32.Parse(off.QuerySelector("page_extent").TextContent);
                    (offer as Book).Delivery          = bool.Parse(off.QuerySelector("delivery").TextContent);
                    (offer as Book).LocalDeliveryCost = Int32.Parse(off.QuerySelector("local_delivery_cost")?.TextContent);
                    break;

                case "audiobook":
                    offer = new Audiobook();
                    (offer as Audiobook).Author          = off.QuerySelector("author").TextContent;
                    (offer as Audiobook).Name            = off.QuerySelector("name").TextContent;
                    (offer as Audiobook).Publisher       = off.QuerySelector("publisher").TextContent;
                    (offer as Audiobook).Year            = Int32.Parse(off.QuerySelector("year").TextContent);
                    (offer as Audiobook).ISBN            = off.QuerySelector("ISBN").TextContent;
                    (offer as Audiobook).Language        = off.QuerySelector("language").TextContent;
                    (offer as Audiobook).PerformedBy     = off.QuerySelector("performed_by").TextContent;
                    (offer as Audiobook).PerformanceType = off.QuerySelector("performance_type").TextContent;
                    (offer as Audiobook).Storage         = off.QuerySelector("storage").TextContent;
                    (offer as Audiobook).Format          = off.QuerySelector("format").TextContent;
                    //  Formats for parse
                    string[] formats = new string[] { "h'h'm'm's's'", "m'm's's'" };
                    (offer as Audiobook).RecordingLength = TimeSpan.ParseExact(off.QuerySelector("recording_length").TextContent, formats, CultureInfo.InvariantCulture);
                    break;

                case "artist.title":
                    offer = new ArtistTitle();
                    (offer as ArtistTitle).Title        = off.QuerySelector("title").TextContent;
                    (offer as ArtistTitle).Year         = Int32.Parse(off.QuerySelector("year").TextContent);
                    (offer as ArtistTitle).Media        = off.QuerySelector("media").TextContent;
                    (offer as ArtistTitle).Artist       = off.QuerySelector("artist")?.TextContent;
                    (offer as ArtistTitle).Starring     = off.QuerySelector("starring")?.TextContent?.Split(',');
                    (offer as ArtistTitle).Director     = off.QuerySelector("director")?.TextContent;
                    (offer as ArtistTitle).OriginalName = off.QuerySelector("originalName")?.TextContent;
                    (offer as ArtistTitle).Country      = off.QuerySelector("country")?.TextContent;
                    break;

                case "tour":
                    offer = new Tour();
                    (offer as Tour).WorldRegion   = off.QuerySelector("worldRegion").TextContent;
                    (offer as Tour).Country       = off.QuerySelector("country").TextContent;
                    (offer as Tour).Region        = off.QuerySelector("region").TextContent;
                    (offer as Tour).Days          = Int32.Parse(off.QuerySelector("days").TextContent);
                    (offer as Tour).DataTourStart = DateTime.Parse(off.QuerySelectorAll("dataTour")[0].TextContent, CultureInfo.InvariantCulture);
                    (offer as Tour).DataTourEnd   = DateTime.Parse(off.QuerySelectorAll("dataTour")[1].TextContent, CultureInfo.InvariantCulture);
                    (offer as Tour).Name          = off.QuerySelector("name").TextContent;
                    (offer as Tour).HotelStars    = Int32.Parse(off.QuerySelector("hotel_stars").TextContent.Replace("*", string.Empty));
                    (offer as Tour).Room          = off.QuerySelector("room").TextContent;
                    (offer as Tour).Meal          = off.QuerySelector("meal").TextContent;
                    (offer as Tour).Included      = off.QuerySelector("included").TextContent.Split(',');
                    (offer as Tour).Transport     = off.QuerySelector("transport").TextContent;
                    break;

                case "event-ticket":
                    offer = new EventTicket();
                    (offer as EventTicket).Name       = off.QuerySelector("name").TextContent;
                    (offer as EventTicket).Place      = off.QuerySelector("place").TextContent;
                    (offer as EventTicket).Hall       = off.QuerySelector("hall").TextContent;
                    (offer as EventTicket).HallPart   = off.QuerySelector("hall_part").TextContent;
                    (offer as EventTicket).Date       = DateTime.Parse(off.QuerySelector("date").TextContent, CultureInfo.InvariantCulture);
                    (offer as EventTicket).IsPremiere = Convert.ToBoolean(Int32.Parse(off.QuerySelector("is_premiere").TextContent));
                    (offer as EventTicket).IsPremiere = Convert.ToBoolean(Int32.Parse(off.QuerySelector("is_kids").TextContent));
                    break;

                default:
                    offer = new BaseOffer();
                    break;
                }
                ParseBaseOffer(off, offer, categories, currencies, localDeliveryCost);
                offers.Add(offer);
            }
            return(offers);
        }
        public ActionResult Edit(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            var vendor = _vendorService.GetVendorById(model.Id);

            if (vendor == null || vendor.Deleted)
            {
                //No vendor found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                int prevPictureId = vendor.PictureId;
                vendor = model.ToEntity(vendor);
                _vendorService.UpdateVendor(vendor);
                //search engine name
                model.SeName = vendor.ValidateSeName(model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);
                //locales
                UpdateLocales(vendor, model);
                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != vendor.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                    {
                        _pictureService.DeletePicture(prevPicture);
                    }
                }
                //update picture seo file name
                UpdatePictureSeoNames(vendor);

                SuccessNotification(_localizationService.GetResource("Admin.Vendors.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return(RedirectToAction("Edit", new { id = vendor.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form

            //associated customer emails
            model.AssociatedCustomers = _customerService
                                        .GetAllCustomers(vendorId: vendor.Id)
                                        .Select(c => new VendorModel.AssociatedCustomerInfo()
            {
                Id    = c.Id,
                Email = c.Email
            })
                                        .ToList();

            return(View(model));
        }
Example #12
0
        public ActionResult Registration(VendorModel _model, HttpPostedFileBase Image, HttpPostedFileBase CopyofTrade)
        {
            if (!CommonData.IsVendorEmailExists(_model.EmailId))
            {
                int _maxLength     = MaxLength * 1024 * 1024;
                int _maxFileLength = MaxFileLength * 1024 * 1024;
                if (ModelState.ContainsKey("ImageFile"))
                {
                    ModelState["ImageFile"].Errors.Clear();
                }
                var imageTypes = new string[] { "image/gif", "image/jpeg", "image/pjpeg", "image/png" };

                if (Image != null)
                {
                    if (!imageTypes.Contains(Image.ContentType))
                    {
                        ModelState.AddModelError("ImageFile", "Please choose either a GIF, JPG or PNG image.");
                    }
                    else if (Image.ContentLength > _maxLength)
                    {
                        ModelState.AddModelError("ImageFile", "Maximum allowed file size is " + MaxLength + " MB.");
                    }
                }

                if (ModelState.ContainsKey("TradeAndBusinessFile"))
                {
                    ModelState["TradeAndBusinessFile"].Errors.Clear();
                }
                if (CopyofTrade != null)
                {
                    string        AlllowedExtension = ".pdf";
                    List <string> extList           = AlllowedExtension.Split(',').ToList <string>();
                    if (!extList.Contains(System.IO.Path.GetExtension(CopyofTrade.FileName)))
                    {
                        ModelState.AddModelError("TradeAndBusinessFile", "Please choose only " + AlllowedExtension + " file.");
                    }
                    else if (CopyofTrade.ContentLength > _maxFileLength)
                    {
                        ModelState.AddModelError("TradeAndBusinessFile", "Maximum allowed file size is " + MaxFileLength + " MB.");
                    }
                }


                //Check if other discipline is selected
                if (CommonData.GetDisciplineList().Where(x => x.Value == _model.DisciplineId.ToString()).FirstOrDefault().Text.ToLower() == "others")
                {
                    if (!string.IsNullOrEmpty(_model.OtherDisciplineName))
                    {
                        if (VendorHelper.Instance.IsDisciplineExists(_model.OtherDisciplineName))
                        {
                            ModelState.AddModelError("OtherDisciplineName", "Discipline already exists");
                        }
                        else
                        {
                            _model.DisciplineId = VendorHelper.Instance.AddOtherDiscipline(_model.OtherDisciplineName);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("OtherDisciplineName", "Other discipline name is required");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(_model.OtherDisciplineName))
                    {
                        _model.OtherDisciplineName = null;
                    }
                }

                long result = VendorHelper.Instance.AddNewVendor(_model, Image, CopyofTrade);


                if (result > 0)
                {
                    EmailSender.FncSend_StratasBoard_RegistrationMail_ToVendor(_model.VendorName, _model.EmailId);
                    TempData["Message"] = AppLogic.setFrontendMessage(0, "You have successfully registered on the StratasFair portal. Your details will be verified by our expert team and you will be notified with your login credentials shortly.");
                    return(RedirectToAction("registration"));
                }
                else if (result == -3)
                {
                    TempData["Message"] = AppLogic.setFrontendMessage(1, "Email ID already exists. Registration Failed");
                }
                else
                {
                    TempData["Message"] = AppLogic.setFrontendMessage(-1, "Registration Failed");
                }
            }
            else
            {
                ModelState.AddModelError("EmailId", "Email already exists.");
            }
            return(View(_model));
        }
Example #13
0
        public async Task <ActionResult> vendorLogin(vendorViewLogin vvl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(vvl));
                }

                AdminLogin admin = new AdminLogin();
                admin = db.adminlog.Where(x => x.EmailAddress == vvl.VendorEmail && (x.Passkey == vvl.VendorPassword)).FirstOrDefault();
                if (admin != null)
                {
                    //Session["superid"] = vvl.VendorEmail;
                    //Session["EmailId"] = vvl.VendorEmail;
                    //ViewBag.messg = vvl.VendorEmail;
                    FormsAuthentication.SetAuthCookie(vvl.VendorEmail, false);
                    string Roles           = "admin";
                    var    authTicket      = new FormsAuthenticationTicket(1, admin.EmailAddress, DateTime.Now, DateTime.Now.AddMinutes(30), false, Roles);
                    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                    var    authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    HttpContext.Response.Cookies.Add(authCookie);
                    return(RedirectToAction("AdminPortal", "SuperAdmin"));
                }
                else
                {
                    string      q      = vvl.VendorPassword;
                    string      pass   = Encrypt_Password(q);
                    VendorModel vendor = new VendorModel();
                    vendor = db.vendor.Where(m => m.VendorEmail == vvl.VendorEmail && (m.VendorPassword == pass)).FirstOrDefault();
                    if (vendor != null)
                    {
                        var id  = db.vendor.Where(m => m.VendorEmail == vvl.VendorEmail).Select(m => m.VendorId).FirstOrDefault();
                        int vid = Convert.ToInt32(id);
                        //Session["Adminid"] = vid;
                        //Session["EmailId"] = vvl.VendorEmail;
                        VendorLogInOutTime vliot = new VendorLogInOutTime();
                        vliot.LogInTime  = DateTime.Now;
                        vliot.VendorId   = vid;
                        vliot.LogOutTime = null;
                        db.loginouttime.Add(vliot);
                        var a = db.vendor.Where(m => m.VendorEmail == vvl.VendorEmail).FirstOrDefault();
                        a.DataCompleted = true;
                        var b = db.businessdetails.Where(x => x.VendorId == id).FirstOrDefault();
                        b.DataCompleted = true;
                        db.SaveChanges();

                        string Roles = db.userrole.Where(x => x.VendorId == vid).Select(x => x.RoleName).FirstOrDefault();
                        FormsAuthentication.SetAuthCookie(vvl.VendorEmail, false);
                        var    authTicket      = new FormsAuthenticationTicket(1, vendor.VendorEmail, DateTime.Now, DateTime.Now.AddMinutes(20), false, Roles);
                        string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                        var    authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                        HttpContext.Response.Cookies.Add(authCookie);
                        return(RedirectToAction("Index", "VendorAccess"));
                    }
                    else
                    {
                        ViewBag.errorvalue = "Please enter valid Login Id and Password.";
                        return(View());
                    }
                }
            }
            catch (Exception e)
            {
                Response.Write("<script>alert('Please enter emailId and password')</script>");
                return(View());
            }
        }
 public static Vendor ToEntity(this VendorModel model)
 {
     return(model.MapTo <VendorModel, Vendor>());
 }
Example #15
0
        protected virtual void PrepareVendorModel(VendorModel model, Vendor vendor, bool excludeProperties, bool prepareEntireAddressModel)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var address = _addressService.GetAddressById(vendor != null ? vendor.AddressId : 0);

            if (vendor != null)
            {
                if (!excludeProperties)
                {
                    if (address != null)
                    {
                        model.Address = address.ToModel();
                    }
                }

                //associated customer emails
                model.AssociatedCustomers = _customerService
                                            .GetAllCustomers(vendorId: vendor.Id)
                                            .Select(c => new VendorModel.AssociatedCustomerInfo()
                {
                    Id    = c.Id,
                    Email = c.Email
                })
                                            .ToList();
            }

            if (prepareEntireAddressModel)
            {
                model.Address.CountryEnabled        = true;
                model.Address.StateProvinceEnabled  = true;
                model.Address.CityEnabled           = true;
                model.Address.StreetAddressEnabled  = true;
                model.Address.StreetAddress2Enabled = true;
                model.Address.ZipPostalCodeEnabled  = true;
                model.Address.PhoneEnabled          = true;
                model.Address.FaxEnabled            = true;

                //address
                model.Address.AvailableCountries.Add(new SelectListItem {
                    Text = _localizationService.GetResource("Admin.Address.SelectCountry"), Value = "0"
                });
                foreach (var c in _countryService.GetAllCountries(showHidden: true))
                {
                    model.Address.AvailableCountries.Add(new SelectListItem {
                        Text = c.Name, Value = c.Id.ToString(), Selected = (address != null && c.Id == address.CountryId)
                    });
                }

                var states = model.Address.CountryId.HasValue ? _stateProvinceService.GetStateProvincesByCountryId(model.Address.CountryId.Value, showHidden: true).ToList() : new List <StateProvince>();
                if (states.Any())
                {
                    foreach (var s in states)
                    {
                        model.Address.AvailableStates.Add(new SelectListItem {
                            Text = s.Name, Value = s.Id.ToString(), Selected = (address != null && s.Id == address.StateProvinceId)
                        });
                    }
                }
                else
                {
                    model.Address.AvailableStates.Add(new SelectListItem {
                        Text = _localizationService.GetResource("Admin.Address.OtherNonUS"), Value = "0"
                    });
                }
            }
        }
Example #16
0
        public JsonResult VendorUpdate(VendorModel model)
        {
            var result = _rep.VendorUpdate(model, User.GetClaimValue(ClaimTypes.Sid));

            return(Json(result));
        }
Example #17
0
        public IHttpActionResult SaveVender(VendorModel model)
        {
            var data = vendorRepo.SaveVender(model);

            return(Ok(data));
        }
Example #18
0
        private void PrepareAclModel(VendorModel model, Vendor vendor, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            model.AvailableCustomerRoles = _customerService
                .GetAllCustomerRoles(true)
                .Select(cr => cr.ToModel())
                .ToList();
            if (!excludeProperties)
            {
                if (vendor != null)
                {
                    model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(vendor);
                }
                else
                {
                    model.SelectedCustomerRoleIds = new int[0];
                }
            }
        }
Example #19
0
        public ActionResult Edit(VendorModel _model)
        {
            try
            {
                // create a bucket if not exists
                string createBucket = AwsS3Bucket.CreateABucket();


                if (ModelState.ContainsKey("ImageType"))
                {
                    ModelState["ImageType"].Errors.Clear();
                }
                var imageTypes = new string[] {
                    "image/gif",
                    "image/jpeg",
                    "image/pjpeg",
                    "image/png"
                };

                int _maxLength = MaxLength * 1024 * 1024;

                if (_model.ImageType != null)
                {
                    if (!imageTypes.Contains(_model.ImageType.ContentType))
                    {
                        ModelState.AddModelError("ImageType", "Please choose either a GIF, JPG or PNG image.");
                    }
                    else if (_model.ImageType.ContentLength > _maxLength)
                    {
                        ModelState.AddModelError("ImageType", "Maximum allowed file size is " + MaxLength + " MB.");
                    }
                    //else if (imageTypes.Contains(_model.ImageType.ContentType) && _model.ImageType.ContentLength <= _maxLength)
                    //{
                    //    System.Drawing.Image img = System.Drawing.Image.FromStream(_model.ImageType.InputStream);
                    //    int height = img.Height;
                    //    int width = img.Width;

                    //    if (width > MaxImageWidth || height > MaxImageHeight)
                    //    {
                    //        ModelState.AddModelError("ImageType", "Maximum allowed file dimension is " + MaxImageWidth + "*" + MaxImageHeight);
                    //    }
                    //}
                }

                if (ModelState.ContainsKey("TradeAndBusinessFileType"))
                {
                    ModelState["TradeAndBusinessFileType"].Errors.Clear();
                }
                int _maxFileLength = MaxFileLength * 1024 * 1024;
                if (_model.TradeAndBusinessFileType != null)
                {
                    string        AlllowedExtension = ".pdf";
                    List <string> extList           = AlllowedExtension.Split(',').ToList <string>();
                    if (!extList.Contains(System.IO.Path.GetExtension(_model.TradeAndBusinessFileType.FileName)))
                    {
                        ModelState.AddModelError("TradeAndBusinessFileType", "Please choose only " + AlllowedExtension + " file.");
                    }
                    else if (_model.TradeAndBusinessFileType.ContentLength > _maxFileLength)
                    {
                        ModelState.AddModelError("TradeAndBusinessFileType", "Maximum allowed file size is " + MaxFileLength + " MB.");
                    }
                }


                if (ModelState.IsValid)
                {
                    VendorHelper _Helper        = new VendorHelper();
                    long         _vendorId      = 0;
                    int?         _adminApproval = 0;
                    string       uniqueId       = Guid.NewGuid().ToString();
                    string       ext            = string.Empty;
                    string       extFile        = string.Empty;

                    if (_model.TradeAndBusinessFileType != null)
                    {
                        extFile = System.IO.Path.GetExtension(_model.TradeAndBusinessFileType.FileName);
                        _model.TradeAndBusinessFile       = uniqueId + extFile;
                        _model.ActualTradeAndBusinessFile = _model.TradeAndBusinessFileType.FileName;
                    }
                    if (_model.ImageType != null)
                    {
                        ext = System.IO.Path.GetExtension(_model.ImageType.FileName);
                        _model.ImageFile       = uniqueId + "_img" + ext;
                        _model.ActualImageFile = _model.ImageType.FileName;
                    }

                    _adminApproval = _model.AdminApprovalPrev;
                    _vendorId      = _Helper.AddUpdate(_model);

                    if (_vendorId > 0)
                    {
                        string initialPath = "resources/vendor/" + _vendorId;

                        // Add/Delete the new trade and business file and image details
                        string path        = string.Empty;
                        string oldfilePath = string.Empty;

                        int fileMapped = -1;
                        if (_model.ImageType != null)
                        {
                            // save the file locally
                            if (!Directory.Exists(Server.MapPath("~/Content/" + initialPath + "/ProfilePicture/")))
                            {
                                Directory.CreateDirectory(Server.MapPath("~/Content/" + initialPath + "/ProfilePicture/"));
                            }
                            // save the file locally
                            path = Server.MapPath(Path.Combine("~/Content/" + initialPath + "/ProfilePicture/" + _model.ImageFile));
                            _model.ImageType.SaveAs(path);

                            // save the file on s3
                            fileMapped = AwsS3Bucket.CreateFile(initialPath + "/ProfilePicture/" + _model.ImageFile, path);

                            // delete the file locally
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }

                            /*******************************************************************************/

                            // delete the old file locally
                            oldfilePath = Server.MapPath("~/Content/Resources/Vendor/" + _vendorId + "/ProfilePicture/" + _model.OldImageFile);
                            if (System.IO.File.Exists(oldfilePath))
                            {
                                System.IO.File.Delete(oldfilePath);
                            }
                            // delete the old file from s3
                            AwsS3Bucket.DeleteObject(initialPath + "/ProfilePicture/" + _model.OldImageFile);

                            /*******************************************************************************/
                        }
                        if (_model.TradeAndBusinessFileType != null)
                        {
                            // save the file locally
                            if (!Directory.Exists(Server.MapPath("~/Content/" + initialPath + "/TradeFile/")))
                            {
                                Directory.CreateDirectory(Server.MapPath("~/Content/" + initialPath + "/TradeFile/"));
                            }
                            path = Server.MapPath("~/Content/Resources/Vendor/" + _vendorId + "/TradeFile/" + _model.TradeAndBusinessFile);
                            _model.TradeAndBusinessFileType.SaveAs(path);

                            // save the file on s3
                            fileMapped = AwsS3Bucket.CreateFile(initialPath + "/TradeFile/" + _model.TradeAndBusinessFile, path);

                            // delete the file locally
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }



                            // delete the old file locally
                            oldfilePath = Server.MapPath("~/Content/Resources/Vendor/" + _vendorId + "/TradeFile/" + _model.OldTradeAndBusinessFile);
                            if (System.IO.File.Exists(oldfilePath))
                            {
                                System.IO.File.Delete(oldfilePath);
                            }
                            // delete the old file from s3
                            AwsS3Bucket.DeleteObject(initialPath + "/TradeFile/" + _model.OldTradeAndBusinessFile);
                        }

                        if (_model.AdminApproval == 2 && _adminApproval != 2)
                        {
                            SendVendorRejectedMail(_vendorId);
                        }

                        if (_model.AdminApproval == 1 && _adminApproval != 1)
                        {
                            SendVendorApprovedMail(_vendorId);
                        }
                        TempData["CommonMessage"] = AppLogic.setMessage(0, "Record updated successfully.");
                        return(RedirectToAction("Index"));
                    }
                    else if (_vendorId == -1)
                    {
                        TempData["CommonMessage"] = AppLogic.setMessage(1, "Record already exists.");
                    }
                    else
                    {
                        TempData["CommonMessage"] = AppLogic.setMessage(2, "Error, Please try again.");
                    }
                }
            }
            catch (Exception ex)
            {
            }
            ViewBag.DisciplineList = CommonData.GetDisciplineWithoutOtherList();
            ViewBag.StatusList     = AppLogic.BindDDStatus(Convert.ToInt32(_model.Status));
            return(View(_model));
        }
Example #20
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();
            if(_vendorService.GetVendorIdByCustomerId(_workContext.CurrentCustomer.Id) > 0)
                return AccessDeniedView();

            var model = new VendorModel();
            //locales
            AddLocales(_languageService, model.Locales);
            //templates
            PrepareTemplatesModel(model);
            //ACL
            PrepareAclModel(model, null, false);
            //default values
            model.PageSize = 4;
            model.Published = true;

            model.AllowCustomersToSelectPageSize = true;
            model.PageSizeOptions = _catalogSettings.DefaultManufacturerPageSizeOptions;//add by hz to do

            return View(model);
        }
Example #21
0
        public virtual IActionResult Edit(VendorModel model, bool continueEditing, IFormCollection form)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            //try to get a vendor with the specified id
            var vendor = _vendorService.GetVendorById(model.Id);

            if (vendor == null || vendor.Deleted)
            {
                return(RedirectToAction("List"));
            }

            //parse vendor attributes
            var vendorAttributesXml = ParseVendorAttributes(form);

            _vendorAttributeParser.GetAttributeWarnings(vendorAttributesXml).ToList()
            .ForEach(warning => ModelState.AddModelError(string.Empty, warning));

            if (ModelState.IsValid)
            {
                var prevPictureId = vendor.PictureId;
                vendor = model.ToEntity(vendor);
                _vendorService.UpdateVendor(vendor);

                //vendor attributes
                _genericAttributeService.SaveAttribute(vendor, NopVendorDefaults.VendorAttributes, vendorAttributesXml);

                //activity log
                _customerActivityService.InsertActivity("EditVendor",
                                                        string.Format(_localizationService.GetResource("ActivityLog.EditVendor"), vendor.Id), vendor);

                //search engine name
                model.SeName = _urlRecordService.ValidateSeName(vendor, model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);

                //address
                var address = _addressService.GetAddressById(vendor.AddressId);
                if (address == null)
                {
                    address = model.Address.ToEntity <Address>();
                    address.CreatedOnUtc = DateTime.UtcNow;

                    //some validation
                    if (address.CountryId == 0)
                    {
                        address.CountryId = null;
                    }
                    if (address.StateProvinceId == 0)
                    {
                        address.StateProvinceId = null;
                    }

                    _addressService.InsertAddress(address);
                    vendor.AddressId = address.Id;
                    _vendorService.UpdateVendor(vendor);
                }
                else
                {
                    address = model.Address.ToEntity(address);

                    //some validation
                    if (address.CountryId == 0)
                    {
                        address.CountryId = null;
                    }
                    if (address.StateProvinceId == 0)
                    {
                        address.StateProvinceId = null;
                    }

                    _addressService.UpdateAddress(address);
                }

                //locales
                UpdateLocales(vendor, model);

                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != vendor.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                    {
                        _pictureService.DeletePicture(prevPicture);
                    }
                }
                //update picture seo file name
                UpdatePictureSeoNames(vendor);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Vendors.Updated"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                return(RedirectToAction("Edit", new { id = vendor.Id }));
            }

            //prepare model
            model = _vendorModelFactory.PrepareVendorModel(model, vendor, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Example #22
0
        public ActionResult Create(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();
            if (customerVendorId > 0)
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var vendor = model.ToEntity();
                vendor.CreatedOnUtc = DateTime.UtcNow;
                vendor.UpdatedOnUtc = DateTime.UtcNow;
                _vendorService.InsertVendor(vendor);
                //search engine name
                model.SeName = vendor.ValidateSeName(model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);
                //locales
                UpdateLocales(vendor, model);
                //update picture seo file name
                UpdatePictureSeoNames(vendor);
                //ACL (customer roles)
                SaveVendorAcl(vendor, model);
                //activity log
                _customerActivityService.InsertActivity("AddNewVendor", _localizationService.GetResource("ActivityLog.AddNewVendor"), vendor.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Vendors.Added"));
                return continueEditing ? RedirectToAction("Edit", new { id = vendor.Id }) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            //templates
            PrepareTemplatesModel(model);
            //ACL
            PrepareAclModel(model, null, true);
            return View(model);
        }
Example #23
0
        public ActionResult Edit(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            var vendor = _vendorService.GetVendorById(model.Id);

            if (vendor == null || vendor.Deleted)
            {
                //No vendor found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                string prevPictureId = vendor.PictureId;
                vendor         = model.ToEntity(vendor);
                vendor.Locales = UpdateLocales(vendor, model);
                model.SeName   = vendor.ValidateSeName(model.SeName, vendor.Name, true);

                //discounts
                var allDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true);
                foreach (var discount in allDiscounts)
                {
                    if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id))
                    {
                        //new discount
                        if (vendor.AppliedDiscounts.Count(d => d.Id == discount.Id) == 0)
                        {
                            vendor.AppliedDiscounts.Add(discount);
                        }
                    }
                    else
                    {
                        //remove discount
                        if (vendor.AppliedDiscounts.Count(d => d.Id == discount.Id) > 0)
                        {
                            vendor.AppliedDiscounts.Remove(discount);
                        }
                    }
                }

                vendor.SeName = model.SeName;

                _vendorService.UpdateVendor(vendor);
                //search engine name
                _urlRecordService.SaveSlug(vendor, model.SeName, "");

                //delete an old picture (if deleted or updated)
                if (!String.IsNullOrEmpty(prevPictureId) && prevPictureId != vendor.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                    {
                        _pictureService.DeletePicture(prevPicture);
                    }
                }
                //update picture seo file name
                UpdatePictureSeoNames(vendor);


                SuccessNotification(_localizationService.GetResource("Admin.Vendors.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = vendor.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            //discounts
            PrepareDiscountModel(model, vendor, true);

            //associated customer emails
            model.AssociatedCustomers = _customerService
                                        .GetAllCustomers(vendorId: vendor.Id)
                                        .Select(c => new VendorModel.AssociatedCustomerInfo()
            {
                Id    = c.Id,
                Email = c.Email
            })
                                        .ToList();

            return(View(model));
        }
Example #24
0
        public ActionResult CustomerAddPopup(string btnId, string formId, VendorModel.AddVendorCustomerModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            if (model.SelectedCustomerIds != null)
            {
                foreach (int id in model.SelectedCustomerIds)
                {
                    var customer = _customerService.GetCustomerById(id);
                    if (customer != null)
                    {
                        var existingVendorCustomers = _vendorService.GetVendorCustomersByVendorId(model.VendorId, 0, int.MaxValue, true);
                        if (existingVendorCustomers.FindVendorCustomer(id, model.VendorId) == null)
                        {
                            _vendorService.InsertVendorCustomer(
                                new VendorCustomer()
                                {
                                    VendorId = model.VendorId,
                                    CustomerId = id,
                                    DisplayOrder = 1
                                });
                        }
                    }
                }
            }

            ViewBag.RefreshPage = true;
            ViewBag.btnId = btnId;
            ViewBag.formId = formId;
            model.Customers = new GridModel<CustomerModel>();
            return View(model);
        }
Example #25
0
        public ActionResult New(string docid, DateTime rdate)
        {
            // Get Login User's details.
            var ur = _userRepo.Find(usr => usr.UserName == User.Identity.Name).FirstOrDefault();

            AssetModel asset = new AssetModel();

            asset.AccDate     = DateTime.Now;
            asset.BuyDate     = DateTime.Now;
            asset.DisposeKind = "正常";
            if (docid != null)
            {
                DeliveryModel dy = _context.Deliveries.Find(docid);
                //BuyEvaluate d = db.BuyEvaluates.Find(dy.PurchaseNo);
                //if (d != null)
                //{
                //    asset.Cname = d.PlantCnam;
                //    asset.Ename = d.PlantEnam;
                //}
                if (dy != null)
                {
                    asset.AccDpt = dy.AccDpt;
                    VendorModel vr = _context.BMEDVendors.Where(v => v.UniteNo == dy.VendorId).FirstOrDefault();
                    asset.VendorId = vr == null ? 0 : vr.VendorId;
                }
                asset.Docid = docid;
            }
            //asset.DelivUid = 34;
            //asset.DelivEmp = "張三";
            //asset.DelivDpt = "8420";
            asset.KeepYm = (rdate.Year - 1911) * 100 + rdate.Month;
            AppUserModel u = _context.AppUsers.Find(ur.Id);

            if (u != null)
            {
                asset.DelivUid = u.Id;
                asset.DelivEmp = u.FullName;
                asset.DelivDpt = u.DptId;

                if (u.DptId != null)
                {
                    asset.AccDpt   = u.DptId;
                    asset.DelivDpt = u.DptId;
                    DepartmentModel co = _context.Departments.Find(u.DptId);
                    if (co != null)
                    {
                        asset.LeaveSite = co.Name_C;
                    }
                }
            }
            //
            List <SelectListItem> listItem = new List <SelectListItem>();
            List <SelectListItem> delivdpt = new List <SelectListItem>();
            List <SelectListItem> accdpt   = new List <SelectListItem>();

            listItem.Add(new SelectListItem {
                Text = asset.DelivEmp, Value = asset.DelivUid.Value.ToString()
            });
            List <AppUserModel> ul;
            string gid = "CCH";

            _context.Departments.ToList()
            .ForEach(o => {
                delivdpt.Add(new SelectListItem
                {
                    Text  = o.Name_C,
                    Value = o.DptId
                });
                accdpt.Add(new SelectListItem
                {
                    Text  = o.Name_C,
                    Value = o.DptId
                });
            });
            ViewData["DelivUids"] = new SelectList(listItem, "Value", "Text");
            ViewData["DelivDpts"] = new SelectList(delivdpt, "Value", "Text", asset.DelivDpt);
            ViewData["AccDpts"]   = new SelectList(accdpt, "Value", "Text", asset.AccDpt);

            return(PartialView(asset));
        }
Example #26
0
 public ActionResult CustomerAddPopupList(GridCommand command, VendorModel.AddVendorCustomerModel model,
    [ModelBinderAttribute(typeof(CommaSeparatedModelBinder))] int[] searchCustomerRoleIds)
 {
     //we use own own binder for searchCustomerRoleIds property
     if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
         return AccessDeniedView();
     var customerRoleVendorMangerId = new[] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.VendorManager).Id };
     var customers = _customerService.GetAllCustomers(null, null,
         customerRoleVendorMangerId, model.SearchEmail, model.SearchUsername,
         model.SearchFirstName, model.SearchLastName,
         0, 0,
         null, null, null,
         false, null, command.Page - 1, command.PageSize);
     var gridModel = new GridModel<CustomerModel>
     {
         Data = customers.Select(PrepareCustomerModelForList),
         Total = customers.TotalCount
     };
     return new JsonResult
     {
         Data = gridModel
     };
 }
Example #27
0
        private async void Submit_Click(object sender, EventArgs e)
        {
            //Emp_Code = FindViewById<EditText>(Resource.Id.txtempcode);
            Store           = FindViewById <EditText>(Resource.Id.txtStore);
            Code            = FindViewById <EditText>(Resource.Id.txtCode);
            Quantity        = FindViewById <EditText>(Resource.Id.txtQuantity);
            VendorName      = FindViewById <EditText>(Resource.Id.txtVendorName);
            VendorContact   = FindViewById <EditText>(Resource.Id.txtVendorContact);
            VendorAddress   = FindViewById <EditText>(Resource.Id.txtVendorAddress);
            VendorCost      = FindViewById <EditText>(Resource.Id.txtVendorCost);
            SellingCost     = FindViewById <EditText>(Resource.Id.txtSellingCost);
            CustomerName    = FindViewById <EditText>(Resource.Id.txtCustomerName);
            CustomerContact = FindViewById <EditText>(Resource.Id.txtCustomerContact);

            VendorModel vendorModel = new VendorModel()
            {
                //emp_code = Emp_Code.Text,
                store           = Store.Text,
                code            = Code.Text,
                quantity        = Quantity.Text,
                vendorname      = VendorName.Text,
                vendorcontact   = VendorContact.Text,
                vendoraddress   = VendorAddress.Text,
                vendorcost      = VendorCost.Text,
                sellingcost     = SellingCost.Text,
                customername    = CustomerName.Text,
                customercontact = CustomerContact.Text,
            };
            ReturnValidation returnValidation = new ReturnValidation();

            if (returnValidation.DecimalValidation(Quantity.Text) && returnValidation.DecimalValidation(VendorCost.Text) && returnValidation.DecimalValidation(SellingCost.Text))
            {
                string            Json              = JsonConvert.SerializeObject(vendorModel);
                HttpContent       stringContent     = new StringContent(Json, encoding: Encoding.UTF8, mediaType: "application/json");
                ReturnGenericPost returnGenericPost = new ReturnGenericPost();
                string            CS = PathLink.VendorURI;

                JObject obj = await returnGenericPost.ReturnGeneralPosMeth(CS, stringContent);

                GetResult getResult1 = obj.ToObject <GetResult>();
                if (getResult1.Status == 1)
                {
                    Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                    AlertDialog alert = dialog.Create();
                    alert.SetTitle("Done");
                    alert.SetMessage("Data is Posted");
                    alert.SetButton("OK", (c, ev) =>
                    {
                        // Ok button click task
                    });
                    alert.Show();
                }
            }
            else
            {
                Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                AlertDialog alert = dialog.Create();
                alert.SetTitle("Validation Error");
                alert.SetMessage("Add genuine values in Quantity or VendorCost or SellingCost Textboxes!!!!");

                alert.SetButton("OK", (c, ev) =>
                {
                    // Ok button click task
                });
                alert.Show();
            }
        }
Example #28
0
        public ActionResult CustomerUpdate(GridCommand command, VendorModel.VendorCustomerModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            var vendorCustomer = _vendorService.GetVendorCustomerById(model.Id);
            if (vendorCustomer == null)
                throw new ArgumentException("No customer vendor mapping found with the specified id");

            vendorCustomer.DisplayOrder = model.DisplayOrder1;
            _vendorService.UpdateVendorCustomer(vendorCustomer);

            return CustomerList(command, vendorCustomer.VendorId);
        }
Example #29
0
 public ActionResult PutVendor(VendorModel vendor) => View();
Example #30
0
        public ActionResult Edit(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)
                 && !_permissionService.Authorize(StandardPermissionProvider.ManageVendor) //add by hz
                )
                return AccessDeniedView();

            var vendor = _vendorService.GetVendorById(model.Id);
            if (vendor == null || vendor.Deleted)
                //No vendor found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                int prevPictureId = vendor.PictureId;
                vendor = model.ToEntity(vendor);
                vendor.UpdatedOnUtc = DateTime.UtcNow;
                _vendorService.UpdateVendor(vendor);
                //search engine name
                model.SeName = vendor.ValidateSeName(model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);
                //locales
                UpdateLocales(vendor, model);
                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != vendor.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                        _pictureService.DeletePicture(prevPicture);
                }
                //update picture seo file name
                UpdatePictureSeoNames(vendor);
                //acl
                SaveVendorAcl(vendor, model);

                //activity log
                _customerActivityService.InsertActivity("EditVendor", _localizationService.GetResource("ActivityLog.EditVendor"), vendor.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Vendors.Updated"));
                return continueEditing ? RedirectToAction("Edit", vendor.Id) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            //templates
            PrepareTemplatesModel(model);
            //Acl
            PrepareAclModel(model, vendor, true);

            return View(model);
        }
Example #31
0
        private async void BtnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                // Emp_Code = view.FindViewById<EditText>(Resource.Id.txtempcode);
                Store           = view.FindViewById <EditText>(Resource.Id.txtStore);
                Code            = view.FindViewById <EditText>(Resource.Id.txtCode);
                Quantity        = view.FindViewById <EditText>(Resource.Id.txtQuantity);
                VendorName      = view.FindViewById <EditText>(Resource.Id.txtVendorName);
                VendorContact   = view.FindViewById <EditText>(Resource.Id.txtVendorContact);
                VendorAddress   = view.FindViewById <EditText>(Resource.Id.txtVendorAddress);
                VendorCost      = view.FindViewById <EditText>(Resource.Id.txtVendorCost);
                SellingCost     = view.FindViewById <EditText>(Resource.Id.txtSellingCost);
                CustomerName    = view.FindViewById <EditText>(Resource.Id.txtCustomerName);
                CustomerContact = view.FindViewById <EditText>(Resource.Id.txtCustomerContact);

                VendorModel vendorModel = new VendorModel()
                {
                    //emp_code = Emp_Code.Text,
                    store           = Store.Text,
                    code            = Code.Text,
                    quantity        = Quantity.Text,
                    vendorname      = VendorName.Text,
                    vendorcontact   = VendorContact.Text,
                    vendoraddress   = VendorAddress.Text,
                    vendorcost      = VendorCost.Text,
                    sellingcost     = SellingCost.Text,
                    customername    = CustomerName.Text,
                    customercontact = CustomerContact.Text,
                };
                ReturnValidation returnValidation = new ReturnValidation();


                if (returnValidation.DecimalValidation(Quantity.Text) && returnValidation.DecimalValidation(VendorCost.Text) && returnValidation.DecimalValidation(SellingCost.Text))
                {
                    string            Json              = JsonConvert.SerializeObject(vendorModel);
                    HttpContent       stringContent     = new StringContent(Json, encoding: Encoding.UTF8, mediaType: "application/json");
                    ReturnGenericPost returnGenericPost = new ReturnGenericPost();
                    string            CS = PathLink.VendorURI;

                    JObject obj = await returnGenericPost.ReturnGeneralPosMeth(CS, stringContent);

                    GetResult getResult1 = obj.ToObject <GetResult>();
                    if (getResult1.Status == 1)
                    {
                        View view = LayoutInflater.Inflate(Resource.Layout.UIVendorModel, null);
                        Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(Context).Create();

                        alert.SetTitle("Done");
                        alert.SetMessage("Data is Posted");
                        //	alert.Dismiss();
                        //	Toast.MakeText(Context, "Alert Dialog dismissed!!!", ToastLength.Short).Show();
                        alert.Show();
                    }
                }
                else
                {
                    Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(Context).Create();
                    alert.SetTitle("What the Hell !!!!");
                    alert.SetMessage("Please add genuine value in Quantity, VendorCost and Selling Textboxes");
                    //alert.Dismiss();
                    alert.Show();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #32
0
        public ActionResult ProductAddPopup(string btnId, string formId, VendorModel.AddVendorProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            if (model.SelectedProductIds != null)
            {
                foreach (int id in model.SelectedProductIds)
                {
                    var product = _productService.GetProductById(id);
                    if (product != null)
                    {
                        var existingProductvendors = _vendorService.GetProductVendorsByVendorId(model.VendorId, 0, int.MaxValue, true);
                        if (existingProductvendors.FindProductVendor(id, model.VendorId) == null)
                        {
                            _vendorService.InsertProductVendor(
                                new ProductVendor()
                                {
                                    VendorId = model.VendorId,
                                    ProductId = id,
                                    IsFeaturedProduct = false,
                                    DisplayOrder = 1
                                });
                        }
                    }
                }
            }

            ViewBag.RefreshPage = true;
            ViewBag.btnId = btnId;
            ViewBag.formId = formId;
            model.Products = new GridModel<ProductModel>();
            return View(model);
        }
Example #33
0
        /// <summary>
        /// Prepare vendor model
        /// </summary>
        /// <param name="model">Vendor model</param>
        /// <param name="vendor">Vendor</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the vendor model
        /// </returns>
        public virtual async Task <VendorModel> PrepareVendorModelAsync(VendorModel model, Vendor vendor, bool excludeProperties = false)
        {
            Action <VendorLocalizedModel, int> localizedModelConfiguration = null;

            if (vendor != null)
            {
                //fill in model values from the entity
                if (model == null)
                {
                    model        = vendor.ToModel <VendorModel>();
                    model.SeName = await _urlRecordService.GetSeNameAsync(vendor, 0, true, false);
                }

                //define localized model configuration action
                localizedModelConfiguration = async(locale, languageId) =>
                {
                    locale.Name = await _localizationService.GetLocalizedAsync(vendor, entity => entity.Name, languageId, false, false);

                    locale.Description = await _localizationService.GetLocalizedAsync(vendor, entity => entity.Description, languageId, false, false);

                    locale.MetaKeywords = await _localizationService.GetLocalizedAsync(vendor, entity => entity.MetaKeywords, languageId, false, false);

                    locale.MetaDescription = await _localizationService.GetLocalizedAsync(vendor, entity => entity.MetaDescription, languageId, false, false);

                    locale.MetaTitle = await _localizationService.GetLocalizedAsync(vendor, entity => entity.MetaTitle, languageId, false, false);

                    locale.SeName = await _urlRecordService.GetSeNameAsync(vendor, languageId, false, false);
                };

                //prepare associated customers
                await PrepareAssociatedCustomerModelsAsync(model.AssociatedCustomers, vendor);

                //prepare nested search models
                PrepareVendorNoteSearchModel(model.VendorNoteSearchModel, vendor);
            }

            //set default values for the new model
            if (vendor == null)
            {
                model.PageSize = 6;
                model.Active   = true;
                model.AllowCustomersToSelectPageSize = true;
                model.PageSizeOptions     = _vendorSettings.DefaultVendorPageSizeOptions;
                model.PriceRangeFiltering = true;
                model.ManuallyPriceRange  = true;
                model.PriceFrom           = NopCatalogDefaults.DefaultPriceRangeFrom;
                model.PriceTo             = NopCatalogDefaults.DefaultPriceRangeTo;
            }

            model.PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyByIdAsync(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode;

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration);
            }

            //prepare model vendor attributes
            await PrepareVendorAttributeModelsAsync(model.VendorAttributes, vendor);

            //prepare address model
            var address = await _addressService.GetAddressByIdAsync(vendor?.AddressId ?? 0);

            if (!excludeProperties && address != null)
            {
                model.Address = address.ToModel(model.Address);
            }
            await _addressModelFactory.PrepareAddressModelAsync(model.Address, address);

            return(model);
        }
Example #34
0
        public ActionResult ProductAddPopupList(GridCommand command, VendorModel.AddVendorProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            var gridModel = new GridModel();
            IList<int> filterableSpecificationAttributeOptionIds = null;
            var products = _productService.SearchProducts(model.SearchCategoryId,
                model.SearchVendorId,
                customerVendorId,//add by hz
                null, null, null, 0, model.SearchProductName, false, false,
                _workContext.WorkingLanguage.Id, new List<int>(),
                ProductSortingEnum.Position, command.Page - 1, command.PageSize,
                false, out filterableSpecificationAttributeOptionIds, true);
            gridModel.Data = products.Select(x => x.ToModel());
            gridModel.Total = products.TotalCount;
            return new JsonResult
            {
                Data = gridModel
            };
        }
Example #35
0
        public IHttpActionResult UpdateVendor(VendorModel model)
        {
            var data = vendorRepo.UpdateVendor(model);

            return(Ok(data));
        }
Example #36
0
        public ActionResult ProductUpdate(GridCommand command, VendorModel.VendorProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            var productVendor = _vendorService.GetProductVendorById(model.Id);
            if (productVendor == null)
                throw new ArgumentException("No product vendor mapping found with the specified id");

            productVendor.IsFeaturedProduct = model.IsFeaturedProduct;
            productVendor.DisplayOrder = model.DisplayOrder1;
            _vendorService.UpdateProductVendor(productVendor);

            return ProductList(command, productVendor.VendorId);
        }
Example #37
0
        public virtual IActionResult Create(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            //parse vendor attributes
            var vendorAttributesXml = ParseVendorAttributes(model.Form);

            _vendorAttributeParser.GetAttributeWarnings(vendorAttributesXml).ToList()
            .ForEach(warning => ModelState.AddModelError(string.Empty, warning));

            if (ModelState.IsValid)
            {
                var vendor = model.ToEntity <Vendor>();
                _vendorService.InsertVendor(vendor);

                //activity log
                _customerActivityService.InsertActivity("AddNewVendor",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewVendor"), vendor.Id), vendor);

                //search engine name
                model.SeName = _urlRecordService.ValidateSeName(vendor, model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);

                //address
                var address = model.Address.ToEntity <Address>();
                address.CreatedOnUtc = DateTime.UtcNow;

                //some validation
                if (address.CountryId == 0)
                {
                    address.CountryId = null;
                }
                if (address.StateProvinceId == 0)
                {
                    address.StateProvinceId = null;
                }
                _addressService.InsertAddress(address);
                vendor.AddressId = address.Id;
                _vendorService.UpdateVendor(vendor);

                //vendor attributes
                _genericAttributeService.SaveAttribute(vendor, NopVendorDefaults.VendorAttributes, vendorAttributesXml);

                //locales
                UpdateLocales(vendor, model);

                //update picture seo file name
                UpdatePictureSeoNames(vendor);

                SuccessNotification(_localizationService.GetResource("Admin.Vendors.Added"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                //selected tab
                SaveSelectedTabName();

                return(RedirectToAction("Edit", new { id = vendor.Id }));
            }

            //prepare model
            model = _vendorModelFactory.PrepareVendorModel(model, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Example #38
0
        protected void PrepareTemplatesModel(VendorModel model)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            var templates = _vendorTemplateService.GetAllVendorTemplates();
            foreach (var template in templates)
            {
                model.AvailableVendorTemplates.Add(new SelectListItem()
                {
                    Text = template.Name,
                    Value = template.Id.ToString()
                });
            }
        }
        public ActionResult Edit(VendorModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
                return AccessDeniedView();

            var vendor = _vendorService.GetVendorById(model.Id);
            if (vendor == null || vendor.Deleted)
                //No vendor found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                int prevPictureId = vendor.PictureId;
                vendor = model.ToEntity(vendor);
                _vendorService.UpdateVendor(vendor);

                //activity log
                _customerActivityService.InsertActivity("EditVendor", _localizationService.GetResource("ActivityLog.EditVendor"), vendor.Id);

                //search engine name
                model.SeName = vendor.ValidateSeName(model.SeName, vendor.Name, true);
                _urlRecordService.SaveSlug(vendor, model.SeName, 0);

                //address
                var address = _addressService.GetAddressById(vendor.AddressId);
                if (address == null)
                {
                    address = model.Address.ToEntity();
                    address.CreatedOnUtc = DateTime.UtcNow;
                    //some validation
                    if (address.CountryId == 0)
                        address.CountryId = null;
                    if (address.StateProvinceId == 0)
                        address.StateProvinceId = null;

                    _addressService.InsertAddress(address);
                    vendor.AddressId = address.Id;
                    _vendorService.UpdateVendor(vendor);
                }
                else
                {
                    address = model.Address.ToEntity(address);
                    //some validation
                    if (address.CountryId == 0)
                        address.CountryId = null;
                    if (address.StateProvinceId == 0)
                        address.StateProvinceId = null;

                    _addressService.UpdateAddress(address);
                }


                //locales
                UpdateLocales(vendor, model);
                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != vendor.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                        _pictureService.DeletePicture(prevPicture);
                }
                //update picture seo file name
                UpdatePictureSeoNames(vendor);

                SuccessNotification(_localizationService.GetResource("Admin.Vendors.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return RedirectToAction("Edit",  new {id = vendor.Id});
                }
                return RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            PrepareVendorModel(model, vendor, true, true);

            return View(model);
        }
Example #40
0
 protected void SaveVendorAcl(Vendor vendor, VendorModel model)
 {
     var existingAclRecords = _aclService.GetAclRecords(vendor);
     var allCustomerRoles = _customerService.GetAllCustomerRoles(true);
     foreach (var customerRole in allCustomerRoles)
     {
         if (model.SelectedCustomerRoleIds != null && model.SelectedCustomerRoleIds.Contains(customerRole.Id))
         {
             //new role
             if (existingAclRecords.Where(acl => acl.CustomerRoleId == customerRole.Id).Count() == 0)
                 _aclService.InsertAclRecord(vendor, customerRole.Id);
         }
         else
         {
             //removed role
             var aclRecordToDelete = existingAclRecords.Where(acl => acl.CustomerRoleId == customerRole.Id).FirstOrDefault();
             if (aclRecordToDelete != null)
                 _aclService.DeleteAclRecord(aclRecordToDelete);
         }
     }
 }
 public static Vendor ToEntity(this VendorModel model, Vendor destination)
 {
     return(model.MapTo(destination));
 }
Example #42
0
        protected void UpdateLocales(Vendor vendor, VendorModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(vendor,
                                                               x => x.Name,
                                                               localized.Name,
                                                               localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.Description,
                                                           localized.Description,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.MetaKeywords,
                                                           localized.MetaKeywords,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.MetaDescription,
                                                           localized.MetaDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(vendor,
                                                           x => x.MetaTitle,
                                                           localized.MetaTitle,
                                                           localized.LanguageId);

                //search engine name
                var seName = vendor.ValidateSeName(localized.SeName, localized.Name, false);
                _urlRecordService.SaveSlug(vendor, seName, localized.LanguageId);
            }
        }
        //
        // GET: /Delivery/Create
        public IActionResult Create(string id = null)
        {
            DeliveryModel r = new DeliveryModel();
            // Get Login User's details.
            var             u = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault();
            DepartmentModel c = _context.Departments.Find(u.DptId);
            VendorModel     v = _context.BMEDVendors.Find(u.VendorId);

            if (id != null)
            {
                BuyEvaluateModel b = _context.BuyEvaluates.Find(id);
                if (b != null)
                {
                    r.EngId    = b.EngId;
                    r.BudgetId = b.BudgetId;
                    int a = 0;
                    if (int.TryParse(b.AccDpt, out a))
                    {
                        c = _context.Departments.Find(b.AccDpt);
                        if (c != null)
                        {
                            r.AccDpt    = c.DptId;
                            r.AccDptNam = c.Name_C;
                        }
                    }
                    else
                    {
                        c = _context.Departments.Where(d => d.Name_C == b.AccDpt).FirstOrDefault();
                        if (c != null)
                        {
                            r.AccDpt    = c.DptId;
                            r.AccDptNam = c.Name_C;
                        }
                    }
                }
            }
            r.DocId    = GetID();
            r.UserId   = u.Id;
            r.UserName = u.FullName;
            c          = _context.Departments.Find(u.DptId);
            if (c != null)
            {
                r.Company = c.DptId == null ? "" : c.Name_C;
                if (r.AccDpt == null)
                {
                    r.AccDpt    = c.DptId == null ? "" : c.DptId;
                    r.AccDptNam = c.DptId == null ? "" : c.Name_C;
                }
            }
            r.Contact    = u.Mobile;
            r.ApplyDate  = DateTime.Now;
            r.PurchaseNo = id;
            r.WartyMon   = 0;
            r.DelivDateR = DateTime.Now;
            _context.Deliveries.Add(r);
            _context.SaveChanges();
            List <SelectListItem> listItem  = new List <SelectListItem>();
            List <SelectListItem> listItem2 = new List <SelectListItem>();
            List <SelectListItem> listItem3 = new List <SelectListItem>();
            List <SelectListItem> listItem4 = new List <SelectListItem>();
            List <SelectListItem> listItem5 = new List <SelectListItem>();
            var          eng   = roleManager.GetUsersInRole("MedEngineer").ToList();
            var          buyer = roleManager.GetUsersInRole("Buyer");
            AppUserModel p;

            foreach (string s in eng)
            {
                p = _context.AppUsers.Where(ur => ur.UserName == s).FirstOrDefault();
                if (p.Status == "Y")
                {
                    listItem.Add(new SelectListItem {
                        Text = "(" + p.UserName + ")" + p.FullName, Value = p.Id.ToString()
                    });
                }
            }
            ViewData["ENG"] = new SelectList(listItem, "Value", "Text");
            //
            foreach (string s2 in buyer)
            {
                p = _context.AppUsers.Where(ur => ur.UserName == s2).FirstOrDefault();
                listItem2.Add(new SelectListItem {
                    Text = p.FullName, Value = p.Id.ToString()
                });
            }
            ViewData["PUR"] = new SelectList(listItem2, "Value", "Text");

            List <BuyVendorModel> bv = _context.BuyVendors.Where(t => t.DocId == id).ToList();

            foreach (BuyVendorModel b in bv)
            {
                listItem3.Add(new SelectListItem {
                    Text = b.VendorNam, Value = b.UniteNo
                });
            }

            ViewData["Vendors"] = new SelectList(listItem3, "Value", "Text");
            //
            //List<objuser> uv = _context.AppUsers.Join(_context.Departments, up => up.DptId, co => co.DptId,
            //    (up, co) => new objuser
            //    {
            //        uid = up.UserId,
            //        uname = up.FullName,
            //        gid = co.GroupId
            //    }).Where(co => co.gid == c.GroupId).ToList();

            List <AppUserModel> uv = _context.AppUsers.ToList();

            uv = uv.OrderBy(urs => urs.UserName).ToList();
            foreach (AppUserModel z in uv)
            {
                listItem4.Add(new SelectListItem {
                    Text = "(" + z.UserName + ")" + z.FullName, Value = z.Id.ToString()
                });
            }
            ViewData["Users"] = new SelectList(listItem4, "Value", "Text");
            ViewData["Item2"] = new SelectList(listItem5, "Value", "Text");
            return(View(r));
        }
Example #44
0
        public ActionResult Add()
        {
            VendorModel vendormodel1 = new VendorModel();

            return(View(vendormodel1));
        }