Beispiel #1
0
        //
        // GET: CreateEdit
        public ActionResult CreateEdit(string sid)
        {
            USupplier supplier = new USupplier();

            supplier.CountrySelect = new SelectList(supplierService.CountryService.GetCountries(), "Id", "Name");
            supplier.CountryId     = countryProg.CountryId.ToString();
            Guid supplierId;

            if (Guid.TryParse(sid, out supplierId))
            {
                ViewBag.Action     = Resources.Global_String_Update;
                supplier._Supplier = supplierService.GetSupplier(supplierId);
            }
            return(View(supplier));
        }
Beispiel #2
0
        public ActionResult CreateEdit(USupplier supplier, string Action = "")
        {
            if (ModelState.IsValid)
            {
                // save log file
                if (supplier.Logo != null && supplier.Logo.ContentLength > 0)
                {
                    string path;
                    var    fileName = Path.GetFileName(supplier.Logo.FileName);
                    if (Action.Equals("Edit") && !string.IsNullOrWhiteSpace(supplier.LogoLocation))
                    {
                        path = Path.Combine(Server.MapPath("~/App_Data/Logos"), supplier.LogoLocation);
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }

                    path = Path.Combine(Server.MapPath("~/App_Data/Logos"), fileName);
                    supplier.Logo.SaveAs(path);
                    supplier._Supplier.LogoLocation = fileName;
                }

                supplier._Supplier.CountryProgrammeId = countryProg.Id;
                supplier._Supplier.IsApproved         = true;

                if (Action.Equals("Edit"))
                {
                    if (supplierService.EditSupplier(supplier._Supplier))
                    {
                        ModelState.Clear();
                        supplier = new USupplier();
                    }
                }
                else
                {
                    if (supplierService.AddSupplier(supplier._Supplier))
                    {
                        ModelState.Clear();
                        supplier = new USupplier();
                    }
                }
            }
            supplier.CountrySelect = new SelectList(supplierService.CountryService.GetCountries(), "Id", "Name");
            return(ListView());
        }
Beispiel #3
0
        public ActionResult AddNewSupplier4PO(USupplier model)
        {
            Supplier supplier = null;

            supplier = supplierService.GetSupplierByName(model.Name, countryProg.Id);
            if (supplier == null)
            {
                supplier                    = new Supplier();
                supplier.Name               = model.Name;
                supplier.Address            = model.Address != null && model.Address.Trim().Length > 0 ? model.Address : Resources.SystemUser_ViewProfile_NotSet.ToUpper();
                supplier.PrimaryPhone       = model.PrimaryPhone != null && model.PrimaryPhone.Trim().Length > 0 ? model.PrimaryPhone : Resources.SystemUser_ViewProfile_NotSet.ToUpper();
                supplier.CountryId          = countryProg.CountryId;
                supplier.CountryProgrammeId = countryProg.Id;
                supplier.IsApproved         = false;
                supplierService.AddSupplier(supplier);
            }
            return(RepopulateSupplierList(supplier.Id));
        }