Пример #1
0
        public async Task <IActionResult> PutLoaiSP(int id, [FromBody] LoaiSP loaiSP)
        {
            if (id != loaiSP.MaLoai)
            {
                return(BadRequest());
            }

            _context.Entry(loaiSP).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoaiSPExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
 public bool AddBooking(BookingDto dataDto)
 {
     if (dataDto != null)
     {
         using (EcommerceDB context = new EcommerceDB())
         {
             if (dataDto.Id <= 0)
             {
                 Booking AddData = new Booking();
                 AddData.Date     = dataDto.Date;
                 AddData.Name     = dataDto.Name;
                 AddData.MobileNo = dataDto.MobileNo;
                 AddData.EmailId  = dataDto.EmailId;
                 AddData.Address  = dataDto.Address;
                 AddData.Remarks  = dataDto.Remarks;
                 AddData.ItemId   = dataDto.ItemId;
                 AddData.IsActive = true;
                 context.Bookings.Add(AddData);
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 var olddata = context.Bookings.FirstOrDefault(x => x.Id == dataDto.Id);
                 if (olddata != null)
                 {
                     olddata.Date     = dataDto.Date;
                     olddata.Name     = dataDto.Name;
                     olddata.MobileNo = dataDto.MobileNo;
                     olddata.EmailId  = dataDto.EmailId;
                     olddata.Address  = dataDto.Address;
                     olddata.Remarks  = dataDto.Remarks;
                     olddata.ItemId   = dataDto.ItemId;
                     olddata.IsActive = true;
                     context.Entry(olddata).Property(x => x.Date).IsModified     = true;
                     context.Entry(olddata).Property(x => x.Name).IsModified     = true;
                     context.Entry(olddata).Property(x => x.MobileNo).IsModified = true;
                     context.Entry(olddata).Property(x => x.EmailId).IsModified  = true;
                     context.Entry(olddata).Property(x => x.Address).IsModified  = true;
                     context.Entry(olddata).Property(x => x.Remarks).IsModified  = true;
                     context.Entry(olddata).Property(x => x.ItemId).IsModified   = true;
                     context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                     olddata.IsActive = true;
                     context.SaveChanges();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Пример #3
0
 public bool AddItemfeature(ItemfeaturesDto dataDto)
 {
     if (dataDto != null)
     {
         using (EcommerceDB context = new EcommerceDB())
         {
             if (dataDto.Id <= 0)
             {
                 Itemfeatures AddData = new Itemfeatures();
                 AddData.Description = dataDto.Description;
                 AddData.ItemId      = dataDto.ItemId;
                 AddData.IsActive    = true;
                 context.Itemfeaturess.Add(AddData);
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 var olddata = context.Itemfeaturess.FirstOrDefault(x => x.Id == dataDto.Id);
                 if (olddata != null)
                 {
                     olddata.Description = dataDto.Description;
                     olddata.IsActive    = true;
                     context.Entry(olddata).Property(x => x.Description).IsModified = true;
                     olddata.ItemId = dataDto.ItemId;
                     context.Entry(olddata).Property(x => x.ItemId).IsModified   = true;
                     context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                     olddata.IsActive = true;
                     context.SaveChanges();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 public bool AddNewlaunchproduct(NewlaunchproductDto dataDto)
 {
     if (dataDto != null)
     {
         using (EcommerceDB context = new EcommerceDB())
         {
             if (dataDto.Id <= 0)
             {
                 Newlaunchproduct AddData = new Newlaunchproduct();
                 AddData.NewlaunchId = dataDto.NewlaunchId;
                 AddData.ItemId      = dataDto.ItemId;
                 AddData.IsActive    = true;
                 context.Newlaunchproducts.Add(AddData);
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 var olddata = context.Newlaunchproducts.FirstOrDefault(x => x.Id == dataDto.Id);
                 if (olddata != null)
                 {
                     olddata.IsActive = true;
                     context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                     olddata.NewlaunchId = dataDto.NewlaunchId;
                     context.Entry(olddata).Property(x => x.NewlaunchId).IsModified = true;
                     olddata.ItemId = dataDto.ItemId;
                     context.Entry(olddata).Property(x => x.ItemId).IsModified = true;
                     olddata.IsActive = true;
                     context.SaveChanges();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Пример #5
0
        public bool DeleteGallery(long id)
        {
            using (EcommerceDB context = new EcommerceDB())
            {
                var data = context.Gallerys.FirstOrDefault(x => x.Id == id);

                if (data != null)
                {
                    data.IsActive = false;
                    context.Entry(data).Property(x => x.IsActive).IsModified = true;
                    context.SaveChanges();

                    return(true);
                }
                return(false);
            }
        }
 public bool ChangePassword(UserDto userDto)
 {
     if (userDto != null)
     {
         using (EcommerceDB context = new EcommerceDB())
         {
             //var token = Request.Headers.Authorization.Parameter;
             //User User = AuthenticationBL.IsTokenValid(token);
             var user         = context.Users.FirstOrDefault(X => X.Id == userDto.Id);
             var passwordSalt = AuthenticationBL.CreatePasswordSalt(Encoding.ASCII.GetBytes(userDto.Password));
             user.PasswordSalt = Convert.ToBase64String(passwordSalt);
             var password = AuthenticationBL.CreateSaltedPassword(passwordSalt, Encoding.ASCII.GetBytes(userDto.Password));
             user.Password             = Convert.ToBase64String(password);
             context.Entry(user).State = EntityState.Modified;
             context.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
Пример #7
0
        public bool AddGallery(GalleryDto dataDto)
        {
            if (dataDto != null)
            {
                using (EcommerceDB context = new EcommerceDB())
                {
                    if (dataDto.Id <= 0)
                    {
                        Gallery AddData = new Gallery();
                        AddData.Name = dataDto.Name;
                        if (dataDto.Img1 != null && dataDto.Img1 != "" && AddData.Img1 != dataDto.Img1 && !dataDto.Img1.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img1.Substring(dataDto.Img1.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            AddData.Img1 = string.Concat("UploadedFiles\\" + id + ".jpg");
                        }
                        if (dataDto.Img2 != null && dataDto.Img2 != "" && AddData.Img2 != dataDto.Img2 && !dataDto.Img2.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img1.Substring(dataDto.Img2.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            AddData.Img2 = string.Concat("UploadedFiles\\" + id + ".jpg");
                        }

                        AddData.IsActive = true;
                        context.Gallerys.Add(AddData);
                        context.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        var olddata = context.Gallerys.FirstOrDefault(x => x.Id == dataDto.Id);
                        if (olddata != null)
                        {
                            olddata.Name = dataDto.Name;
                            if (dataDto.Img1 != null && dataDto.Img1 != "" && olddata.Img1 != dataDto.Img1 && !dataDto.Img1.Contains("http"))
                            {
                                Guid   id      = Guid.NewGuid();
                                var    imgData = dataDto.Img1.Substring(dataDto.Img1.IndexOf(",") + 1);
                                byte[] bytes   = Convert.FromBase64String(imgData);
                                Image  image;
                                using (MemoryStream ms = new MemoryStream(bytes))
                                {
                                    image = Image.FromStream(ms);
                                }
                                Bitmap b        = new Bitmap(image);
                                string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                                b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                                olddata.Img1 = string.Concat("UploadedFiles\\" + id + ".jpg");
                                context.Entry(olddata).Property(x => x.Img1).IsModified = true;
                            }
                        }
                        if (dataDto.Img2 != null && dataDto.Img2 != "" && olddata.Img2 != dataDto.Img2 && !dataDto.Img2.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img2.Substring(dataDto.Img2.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            olddata.Img2 = string.Concat("UploadedFiles\\" + id + ".jpg");
                            context.Entry(olddata).Property(x => x.Img2).IsModified = true;
                        }
                        olddata.IsActive = true;
                        context.Entry(olddata).Property(x => x.Name).IsModified = true;

                        context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                        olddata.IsActive = true;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }