Example #1
0
        public bool Edit(ProductViewModel product, string fileStream)
        {
            try
            {
                Product prod = db.Products.Find(product.ProductID);
                prod.Artist       = product.Artist;
                prod.CategoryID   = product.selectedCategoryID;
                prod.Description  = product.Description;
                prod.Name         = product.Name;
                prod.PremiereDate = product.PremiereDate;
                prod.Price        = product.Price;

                if (fileStream != null)
                {
                    var extension = fileStream.Substring(fileStream.IndexOf(':') + 1);
                    var extLength = extension.IndexOf(';');
                    var allLength = extension.Length - extLength;
                    extension = extension.Remove(extLength, allLength);

                    var file = fileStream.Substring(fileStream.IndexOf(',') + 1);

                    var bytes = Convert.FromBase64String(file);
                    prod.PictureMimeType = extension;
                    prod.PictureData     = bytes;
                }
                db.Entry(prod).State = EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
        public bool EditShippingDetails(ShippingDetailsViewModel model)
        {
            try
            {
                var shipping = Mapper.Map <ShippingDetails>(model);
                db.Entry(shipping).State = EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);

                throw new Exception("Nie można edytować obiektu danych odbiorcy!");
            }
        }
Example #3
0
 public bool Edit(CategoryViewModel category)
 {
     try
     {
         Category cat = db.Categories.Find(category.CategoryID);
         cat.Name            = category.Name;
         cat.Description     = category.Description;
         db.Entry(cat).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }