Esempio n. 1
0
 public int SaveItemDetails(ItemDetailsDto itemDetailsDto)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("SaveAndUpdateItemDetails", connectionRepository.con);
         cmd.Parameters.AddWithValue("@ItemDetailsId", itemDetailsDto.ItemDetailsId);
         cmd.Parameters.AddWithValue("@ItemId", itemDetailsDto.ItemId);
         cmd.Parameters.AddWithValue("@Width", itemDetailsDto.Width);
         cmd.Parameters.AddWithValue("@WidthType", itemDetailsDto.WidthType);
         cmd.Parameters.AddWithValue("@Height", itemDetailsDto.Height);
         cmd.Parameters.AddWithValue("@HeightType", itemDetailsDto.HeightType);
         cmd.Parameters.AddWithValue("@Mrp", itemDetailsDto.Mrp);
         cmd.Parameters.AddWithValue("@Discount", itemDetailsDto.Discount);
         cmd.Parameters.AddWithValue("@Price", itemDetailsDto.Price);
         cmd.Parameters.AddWithValue("@CreatedBy", itemDetailsDto.CreatedBy);
         cmd.Parameters.AddWithValue("@ModifiedBy", itemDetailsDto.ModifiedBy);
         cmd.Parameters.AddWithValue("@IsActive", itemDetailsDto.IsActive);
         cmd.CommandType = CommandType.StoredProcedure;
         connectionRepository.con.Open();
         int i = cmd.ExecuteNonQuery();
         connectionRepository.con.Close();
         return(i);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        public List <ItemDetailsDto> GetAndEditItemDetails(int ItemDetailsId, int IsActive)
        {
            List <ItemDetailsDto> lstItemDetailsDto = new List <ItemDetailsDto>();
            SqlCommand            cmd = new SqlCommand("GetAndEditItemDetails", connectionRepository.con);

            cmd.Parameters.AddWithValue("@ItemDetailsId", ItemDetailsId);
            cmd.Parameters.AddWithValue("@IsActive", IsActive);
            cmd.CommandType = CommandType.StoredProcedure;
            connectionRepository.con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                ItemDetailsDto itemDetailsDto = new ItemDetailsDto();
                itemDetailsDto.ItemDetailsId = Convert.ToInt32(dr["ItemDetailsId"]);
                itemDetailsDto.ItemId        = Convert.ToInt32(dr["ItemId"]);
                itemDetailsDto.ItemName      = Convert.ToString(dr["ItemName"]);
                itemDetailsDto.Width         = Convert.ToDecimal(dr["Width"]);
                itemDetailsDto.WidthType     = Convert.ToString(dr["WidthType"]);
                itemDetailsDto.Height        = Convert.ToDecimal(dr["Height"]);
                itemDetailsDto.HeightType    = Convert.ToString(dr["HeightType"]);
                itemDetailsDto.Mrp           = Convert.ToDecimal(dr["Mrp"]);
                itemDetailsDto.Discount      = Convert.ToDecimal(dr["Discount"]);
                itemDetailsDto.Price         = Convert.ToDecimal(dr["Price"]);
                itemDetailsDto.CreatedBy     = Convert.ToInt32(dr["CreatedBy"]);
                itemDetailsDto.CreatedDate   = Convert.ToString(dr["CreatedDate"]);
                itemDetailsDto.ModifiedBy    = Convert.ToInt32(dr["ModifiedBy"] != DBNull.Value ? dr["ModifiedBy"] : 0);
                itemDetailsDto.ModifiedDate  = Convert.ToString(dr["ModifiedDate"] != DBNull.Value ? dr["ModifiedDate"] : "");
                itemDetailsDto.IsActive      = Convert.ToInt32(dr["IsActive"]);
                lstItemDetailsDto.Add(itemDetailsDto);
            }
            connectionRepository.con.Close();
            return(lstItemDetailsDto);
        }
Esempio n. 3
0
 public ActionResult EditItem(ItemDetailsDto model)
 {
     if (_itemService.EditItem(model))
     {
         return(RedirectToAction("ItemDetails", "Item", _itemService.ItemDetails(model.ItemId)));
     }
     else
     {
         return(RedirectToAction("ErrorInItemEditing"));
     }
 }
Esempio n. 4
0
 public ActionResult SaveItemDetails(ItemDetailsDto itemDetailsDto)
 {
     try
     {
         ItemDetailsDal itemDetailsDal = new ItemDetailsDal();
         itemDetailsDto.CreatedBy  = Convert.ToInt32(Session["AdminId"]);
         itemDetailsDto.ModifiedBy = Convert.ToInt32(Session["AdminId"]);
         itemDetailsDto.IsActive   = 1;
         int i = itemDetailsDal.SaveItemDetails(itemDetailsDto);
         return(Json(i, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
        public ItemDetailsDto ItemDetails(int itemId)
        {
            var            item        = _database.Items.Find(itemId);
            var            imagePath   = _database.Images.Where(a => a.ItemId == item.Id).Select(a => a.ImagePath).First();
            ItemDetailsDto itemDetails = new ItemDetailsDto
            {
                Name         = item.Name,
                CategoryId   = item.CategoryId,
                Description  = item.Description,
                NumberOfItem = item.NumberOfItem,
                PricePerOne  = item.PricePerOne,
                ImagePath    = imagePath,
                ItemId       = itemId
            };


            return(itemDetails);
        }
Esempio n. 6
0
        public bool EditItem(ItemDetailsDto model)
        {
            try
            {
                var item = GetItemById(model.ItemId);
                item.Name         = model.Name;
                item.CategoryId   = model.CategoryId;
                item.Description  = model.Description;
                item.NumberOfItem = model.NumberOfItem;
                item.PricePerOne  = model.PricePerOne;

                _database.Entry(item).State = EntityState.Modified;
                _database.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> GetItemDetailsByItemID(Guid itemID)
        {
            try
            {
                if (itemID == null)
                {
                    return(BadRequest(" Somting Went Wrong :( "));
                }

                var data = (await Db.TblItems.FirstOrDefaultAsync(i => i.PkItemsId == itemID && i.Quantity > 0 && i.IsDeleted != true));
                if (data == null)
                {
                    return(BadRequest(" Somting Went Wrong :( "));
                }
                var itemdata = new ItemDetailsDto()
                {
                    pk_Items_Id    = data.PkItemsId,
                    Name           = data.Name,
                    Description    = data.Description,
                    MainImageUrl   = data.MainImageUrl,
                    Code           = data.Code,
                    Color          = data.Color,
                    Quantity       = data.Quantity,
                    SafeLimit      = data.SafeLimit,
                    RetailPrice    = data.RetailPrice,
                    SupplyPrice    = data.SupplyPrice,
                    WholesalePrice = data.WholesalePrice,
                    IsDeleted      = (bool)data.IsDeleted,
                    fk_subCategories_Items_SubcategoryId = data.FkSubCategoriesItemsSubcategoryId,
                    InitialQuantity = "1",
                };
                return(Ok(itemdata));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }