コード例 #1
0
 /// <summary>
 /// this methos is used to get item details by item id.
 /// </summary>
 /// <param name="itemId"></param>
 /// <returns></returns>
 public ItemProfileAC GetItemProfileByItemId(int itemId)
 {
     try
     {
         var itemProfile       = new ItemProfileAC();
         var itemProfileDetail = _itemProfileContext.FirstOrDefault(x => x.Id == itemId && x.IsDeleted == false);
         if (itemProfileDetail != null)
         {
             var itemQuantiyCollection = new List <ItemQuantityList>();
             var itemQuantityList      = new ItemQuantityList();
             itemProfile = ApplicationClassHelper.ConvertType <ItemProfile, ItemProfileAC>(itemProfileDetail);
             itemProfile.ItemProfileId = itemProfileDetail.Id;
             itemProfile.ItemType      = itemProfileDetail.Category.BrandParamType.ValueEn + "-" + itemProfileDetail.Category.GroupParamType.ValueEn;
             var posIncidentReportDetails = _posIncidentReportDataRepository.FirstOrDefault(x => x.ItemId == itemProfileDetail.Id);
             itemProfile.PosIncidentReportId = posIncidentReportDetails.Id;
             var posIncidentDetails = _posIncidentReportDataRepository.FirstOrDefault(x => x.ItemId == itemId);
             if (posIncidentDetails != null)
             {
                 itemProfile.BranchId   = (int)posIncidentDetails.BranchId;
                 itemProfile.BranchName = posIncidentDetails.BranchDetail.Name;
             }
             var itemQuantityDetails = _itemQuantityContext.FirstOrDefault(x => x.ItemId == itemProfile.Id && x.Branch.CompanyId == itemProfileDetail.CompanyId);
             if (itemQuantityDetails != null)
             {
                 itemQuantityList = ApplicationClassHelper.ConvertType <ItemQuantity, ItemQuantityList>(itemQuantityDetails);
                 itemQuantityList.ItemQuantityId  = itemQuantityDetails.Id;
                 itemProfile.BranchId             = itemQuantityDetails.BranchId;
                 itemProfile.ActualQuantity       = itemQuantityDetails.ActualQuantity;
                 itemQuantityList.MaximumQuantity = itemQuantityDetails.MaxQuantity;
                 itemQuantityList.MinimumQuantity = itemQuantityDetails.MinQuantity;
             }
             itemQuantiyCollection.Add(itemQuantityList);
             itemProfile.ListOfItemQuantityList = itemQuantiyCollection;
         }
         return(itemProfile);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #2
0
 public IHttpActionResult UpdateItemDetails(ItemProfileAC itemDetails)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             int posIncidentReportId = _incidentReportRepository.UpdateItemDetails(itemDetails);
             return(Ok(new { posIncidentReportId = posIncidentReportId }));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #3
0
        /// <summary>
        /// this method is used to update item details.
        /// </summary>
        /// <param name="itemDetails"></param>
        /// <returns></returns>
        public int UpdateItemDetails(ItemProfileAC itemDetails)
        {
            try
            {
                //used for update item profile
                var itemProfileDetail   = _itemProfileContext.FirstOrDefault(x => x.Id == itemDetails.ItemProfileId);
                int posIncidentReportId = 0;
                if (itemProfileDetail != null)
                {
                    itemProfileDetail.ItemNameEn       = itemDetails.ItemNameEn;
                    itemProfileDetail.ItemNameSl       = itemDetails.ItemNameSl;
                    itemProfileDetail.FlavourEn        = itemDetails.FlavourEn;
                    itemProfileDetail.FlavourSl        = itemDetails.FlavourSl;
                    itemProfileDetail.Barcode          = itemDetails.Barcode;
                    itemProfileDetail.UnitParamTypeId  = itemDetails.UnitParamTypeId;
                    itemProfileDetail.Code             = itemDetails.Code;
                    itemProfileDetail.BaseUnit         = itemDetails.BaseUnit;
                    itemProfileDetail.CategoryId       = itemDetails.CategoryId;
                    itemProfileDetail.IsOfferItem      = itemDetails.IsOfferItem;
                    itemProfileDetail.IsActive         = itemDetails.IsActive;
                    itemProfileDetail.IsAutomaticPO    = itemDetails.IsAutomaticPO;
                    itemProfileDetail.ProfitMargin     = itemDetails.ProfitMargin;
                    itemProfileDetail.SellPrice        = itemDetails.SellPrice;
                    itemProfileDetail.SellPriceA       = itemDetails.SellPriceA;
                    itemProfileDetail.SellPriceB       = itemDetails.SellPriceB;
                    itemProfileDetail.SellPriceB       = itemDetails.SellPriceB;
                    itemProfileDetail.SellPriceC       = itemDetails.SellPriceC;
                    itemProfileDetail.SellPriceD       = itemDetails.SellPriceD;
                    itemProfileDetail.CostPrice        = itemDetails.CostPrice;
                    itemProfileDetail.ModifiedDateTime = DateTime.UtcNow;
                    _itemProfileContext.Update(itemProfileDetail);
                    _itemProfileContext.SaveChanges();

                    foreach (var itemQuantityObject in itemDetails.ListOfItemQuantityList)
                    {
                        var itemQuantityDetails =
                            _itemQuantityContext.FirstOrDefault(
                                x => x.ItemId == itemProfileDetail.Id && x.BranchId == itemQuantityObject.BranchId);
                        if (itemQuantityDetails != null)
                        {
                            if (itemQuantityDetails.BranchId != 0)
                            {
                                itemQuantityDetails.ActualQuantity   = itemQuantityObject.ActualQuantity;
                                itemQuantityDetails.MaxQuantity      = itemQuantityObject.MaximumQuantity;
                                itemQuantityDetails.MinQuantity      = itemQuantityObject.MinimumQuantity;
                                itemQuantityDetails.ModifiedDateTime = DateTime.UtcNow;
                                _itemQuantityContext.Update(itemQuantityDetails);
                                _itemQuantityContext.SaveChanges();
                            }
                        }
                        else
                        {
                            var itemQuantity = new ItemQuantity
                            {
                                ActualQuantity  = itemQuantityObject.ActualQuantity,
                                BranchId        = itemDetails.BranchId,
                                CreatedDateTime = DateTime.UtcNow,
                                ItemId          = itemProfileDetail.Id,
                                MaxQuantity     = itemQuantityObject.MaximumQuantity,
                                MinQuantity     = itemQuantityObject.MinimumQuantity
                            };
                            _itemQuantityContext.Add(itemQuantity);
                            _itemQuantityContext.SaveChanges();
                        }
                    }
                }
                return(posIncidentReportId = itemDetails.PosIncidentReportId);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
コード例 #4
0
        /// <summary>
        /// This method used to form a list of items according to their suppliers - JJ
        /// </summary>
        /// <param name="BranchId"></param>
        /// <param name="item"></param>
        /// <returns>list of objects of ItemProfileAC</returns>
        private List <ItemProfileAC> GetItemProfileAcObject(ItemProfile item, int BranchId)
        {
            try
            {
                ItemProfileAC        itemProfileAc;
                List <ItemProfileAC> itemList = new List <ItemProfileAC>();
                var supplierList = _itemSupplierContext.Fetch(x => x.CategoryId == item.CategoryId).ToList();
                foreach (var supplier in supplierList)
                {
                    itemProfileAc = new ItemProfileAC();
                    itemProfileAc.AverageCostPrice                 = item.AverageCostPrice;
                    itemProfileAc.Barcode                          = item.Barcode;
                    itemProfileAc.BaseUnit                         = item.BaseUnit;
                    itemProfileAc.CategoryId                       = item.CategoryId;
                    itemProfileAc.SupplierId                       = supplier.SupplierProfile.Id;
                    itemProfileAc.SupplierName                     = supplier.SupplierProfile.NameEn;
                    itemProfileAc.Code                             = item.Code;
                    itemProfileAc.CostPrice                        = item.CostPrice;
                    itemProfileAc.FlavourEn                        = item.FlavourEn;
                    itemProfileAc.FlavourSl                        = item.FlavourSl;
                    itemProfileAc.HasOffer                         = item.HasOffer;
                    itemProfileAc.IsActive                         = item.IsActive;
                    itemProfileAc.IsIcrApproved                    = item.IsIcrApproved;
                    itemProfileAc.IsItemChangeRequestGenerated     = item.IsItemChangeRequestGenerated;
                    itemProfileAc.IsSupplierReturnRequestGenerated = item.IsSupplierReturnRequestGenerated;
                    itemProfileAc.IsOfferItem                      = item.IsOfferItem;
                    itemProfileAc.IsParentItem                     = item.IsParentItem;
                    itemProfileAc.ItemNameEn                       = item.ItemNameEn;
                    itemProfileAc.ItemNameSl                       = item.ItemNameSl;
                    itemProfileAc.OldRequestQuantity               = 0;
                    itemProfileAc.PreviousCostPrice                = item.PreviousCostPrice;
                    itemProfileAc.ProfitMargin                     = item.ProfitMargin;
                    itemProfileAc.SellPrice                        = item.SellPrice;
                    itemProfileAc.SellPriceA                       = item.SellPriceA;
                    itemProfileAc.SellPriceB                       = item.SellPriceB;
                    itemProfileAc.SellPriceC                       = item.SellPriceC;
                    itemProfileAc.SellPriceD                       = item.SellPriceD;
                    itemProfileAc.UnitParamTypeId                  = item.UnitParamTypeId;
                    itemProfileAc.Id           = item.Id;
                    itemProfileAc.ItemId       = item.Id;
                    itemProfileAc.ItemType     = item.Category.BrandParamType.ValueEn + "-" + item.Category.GroupParamType.ValueEn;
                    itemProfileAc.Unit         = item.SystemParameter.ValueEn;
                    itemProfileAc.HasChildItem = _iItemRepository.CheckAnySubItemIsExists(item.Id);

                    if (itemProfileAc.IsParentItem)
                    {
                        itemProfileAc.ParentItemId = item.Id;
                        var itemQuantity = _iItemRepository.GetItemQuantityByItemId(itemProfileAc.Id, Convert.ToInt32(BranchId));
                        itemProfileAc.SystemQuantity       = itemQuantity != null ? itemQuantity.ActualQuantity : 0;
                        itemProfileAc.UpdateSystemQunatity = itemProfileAc.SystemQuantity;
                    }
                    else
                    {
                        itemProfileAc.ParentItemId = item.ParentItemId;
                        if (itemProfileAc.BaseUnit > 0)
                        {
                            var itemQuantity = _iItemRepository.GetItemQuantityByItemId((int)itemProfileAc.ParentItemId, Convert.ToInt32(BranchId));
                            itemProfileAc.SystemQuantity = itemQuantity != null?Math.Floor((decimal)(itemQuantity.ActualQuantity / itemProfileAc.BaseUnit)) : 0;

                            itemProfileAc.UpdateSystemQunatity = itemQuantity.ActualQuantity;
                        }
                        else
                        {
                            itemProfileAc.SystemQuantity = 0;
                        }
                    }
                    itemProfileAc.ActualQuantity = Convert.ToInt32(itemProfileAc.SystemQuantity);
                    itemList.Add(itemProfileAc);
                }
                return(itemList);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }