public void UpsertContentSlider(ContentSliders input)
        {
            try
            {
                if (input.Id == null)
                {
                    int seqCtr             = 0;
                    var contentslidersList = (from s in db.ContentSliders
                                              where s.IsDeleted == false
                                              select s.Sequence).ToList();
                    if (contentslidersList.Count > 0)
                    {
                        seqCtr = contentslidersList.Max();
                    }

                    input.Id       = Guid.NewGuid();
                    input.Sequence = seqCtr + 1;

                    db.ContentSliders.Add(input);
                    db.SaveChanges();
                }
                else
                {
                    db.Entry(input).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IHttpActionResult PutContentSlider(string id, ContentSliders ContentSlider, string MoveUpId, string MoveDownId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (new Guid(id) != ContentSlider.Id)
            {
                return(BadRequest());
            }

            if (!string.IsNullOrEmpty(MoveUpId))
            {
                _repo.MoveUpContentSlider(MoveUpId);
            }
            else if (!string.IsNullOrEmpty(MoveDownId))
            {
                _repo.MoveDownContentSlider(MoveDownId);
            }
            else
            {
                _repo.UpsertContentSlider(ContentSlider);
            }


            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostContentSlider(ContentSliders ContentSlider)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _repo.UpsertContentSlider(ContentSlider);

            return(CreatedAtRoute("DefaultApi", new { id = ContentSlider.Id }, ContentSlider));
        }
        public IHttpActionResult GetContentSlider(string id)
        {
            ContentSliders ContentSlider = _repo.GetContentSlider(id);

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

            return(Ok(ContentSlider));
        }
        public ActionResult Update(ContentSliders contentsliders)
        {
            if (ModelState.IsValid)
            {
                db = new StorehouseDBContext();

                if (Request.Files["contentslidersImage"].ContentLength > 0)
                {
                    FileInfo contentslidersImageInfo = new FileInfo(Request.Files["contentslidersImage"].FileName);
                    string   webRootPath             = Server.MapPath("~");

                    string contentslidersImageFilename = string.Concat(ConfigurationManager.AppSettings["UploadFilePath"], "ContentSliders/", contentsliders.Id.ToString(), contentslidersImageInfo.Extension);
                    Request.Files["contentslidersImage"].SaveAs(Server.MapPath(contentslidersImageFilename));
                    contentsliders.SlideImage = contentslidersImageFilename;
                }

                db.Entry(contentsliders).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "ContentSliders"));
        }
        public ActionResult Add(ContentSliders contentsliders)
        {
            if (ModelState.IsValid)
            {
                db = new StorehouseDBContext();
                int seqCtr = 0;

                if (TempData["TenantId"] != null)
                {
                    tenantId = TempData["TenantId"].ToString();
                }

                var contentslidersList = (from s in db.ContentSliders
                                          where s.IsDeleted == false &&
                                          s.TenantId == tenantId
                                          select s.Sequence).ToList();
                if (contentslidersList.Count > 0)
                {
                    seqCtr = contentslidersList.Max();
                }

                contentsliders.Id       = Guid.NewGuid();
                contentsliders.Sequence = seqCtr + 1;


                if (Request.Files["contentslidersImage"].ContentLength > 0)
                {
                    FileInfo contentslidersImageInfo = new FileInfo(Request.Files["contentslidersImage"].FileName);
                    string   webRootPath             = Server.MapPath("~");

                    string contentslidersImageFilename = string.Concat(ConfigurationManager.AppSettings["UploadFilePath"], "ContentSliders/", contentsliders.Id.ToString(), contentslidersImageInfo.Extension);
                    Request.Files["contentslidersImage"].SaveAs(Server.MapPath(contentslidersImageFilename));
                    contentsliders.SlideImage = contentslidersImageFilename;
                }

                db.ContentSliders.Add(contentsliders);
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "ContentSliders"));
        }