public IHttpActionResult GetSupplierProfileList()
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             var supplierList       = _supplierProfileContext.GetSupplierList(companyId);
             var supplierCollection = new List <SupplierProfileAC>();
             var supplierAC         = new SupplierProfileAC();
             foreach (var supplier in supplierList)
             {
                 supplierAC    = ApplicationClassHelper.ConvertType <SupplierProfile, SupplierProfileAC>(supplier);
                 supplierAC.Id = supplier.Id;
                 supplierAC.IsAcceptReturnForExpiredItem = supplier.IsAcceptReturnForExpiredItem;
                 supplierCollection.Add(supplierAC);
             }
             return(Ok(supplierCollection));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Example #2
0
 /// <summary>
 /// This method is used for insert new supplier profile in database. - JJ
 /// </summary>
 /// <param name="supplierProfile"> object of SupplierProfileAC</param>
 /// <param name="companyId"></param>
 /// <returns>object of SupplierProfileAC</returns>
 public SupplierProfileAC SaveSupplierProfile(SupplierProfileAC supplierProfile, int companyId)
 {
     try
     {
         if (CheckSupplierCodeIdExist(supplierProfile.Code, supplierProfile.Id, companyId))
         {
             supplierProfile.Code = "";
             return(supplierProfile);
         }
         else if (CheckSupplierPhoneIdExist(supplierProfile.Phone, supplierProfile.Id))
         {
             supplierProfile.Phone = "";
             return(supplierProfile);
         }
         else if (CheckSupplierEmailIdExist(supplierProfile.Email, supplierProfile.Id))
         {
             supplierProfile.Email = "";
             return(supplierProfile);
         }
         var supplierProfiles = new SupplierProfile
         {
             Code           = supplierProfile.Code,
             CompanyId      = companyId,
             NameEn         = supplierProfile.NameEn,
             NameSl         = supplierProfile.NameSl,
             AddressEn      = supplierProfile.AddressEn,
             AddressSl      = supplierProfile.AddressSl,
             Phone          = supplierProfile.Phone,
             Fax            = supplierProfile.Fax,
             Email          = supplierProfile.Email,
             ZipCode        = supplierProfile.ZipCode,
             TotalDaysLimit = supplierProfile.TotalDaysLimit,
             POBox          = supplierProfile.POBox,
             SupplierTypeId = supplierProfile.SupplierTypeId,
             IsDeleted      = supplierProfile.IsDeleted,
             IsActive       = true,
             IsAcceptReturnForExpiredItem = supplierProfile.IsAcceptReturnForExpiredItem,
             CreatedDateTime = DateTime.UtcNow
         };
         _supplierProfileContext.Add(supplierProfiles);
         _supplierProfileContext.SaveChanges();
         supplierProfile.Id = supplierProfiles.Id;
         var creditTypeId = _paramTypeContext.FirstOrDefault(x => x.Param.Value == StringConstants.SupplierType && x.ValueEn == StringConstants.Credit).Id;
         if (supplierProfiles.SupplierTypeId == creditTypeId && supplierProfile.TotalDaysLimit > 0)
         {
             AddDaysLimit(supplierProfile.DiscountDays, supplierProfiles.Id, supplierProfile.Discount, supplierProfile.Days);
         }
         return(supplierProfile);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
 public IHttpActionResult SaveSupplier(SupplierProfileAC supplier)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             if (MerchantContext.Permission.IsAllowToCreateSupplierProfile)
             {
                 var supplierProfileAC = _supplierProfileContext.SaveSupplierProfile(supplier, companyId);
                 if (supplierProfileAC != null && supplierProfileAC.Id > 0)
                 {
                     Ledgers ledgers = new Ledgers();
                     ledgers.Address         = supplierProfileAC.AddressEn;
                     ledgers.State           = "Gujarat";
                     ledgers.CompanyId       = MerchantContext.CompanyDetails.Id;
                     ledgers.LedgerName      = supplierProfileAC.NameEn + "Ledgers";
                     ledgers.Name            = ledgers.LedgerName;
                     ledgers.CreatedDateTime = DateTime.UtcNow;
                     ledgers.GroupId         = 6;
                     ledgers.ParentLedgerId  = null;
                     ledgers.Balance         = 0;
                     ledgers.SuplierId       = supplierProfileAC.Id;
                     _iAccountingRepository.AddAccountLedger(ledgers);
                 }
                 return(Ok(supplierProfileAC));
             }
             else
             {
                 return(Ok(new { status = StringConstants.PermissionDenied }));
             }
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (PhoneNumberIsAlreadyExists)
     {
         return(BadRequest("PhoneNumberIsAlreadyExists"));
     }
     catch (EmailisAlreadyExists)
     {
         return(BadRequest("EmailisAlreadyExists"));
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Example #4
0
 /// <summary>
 /// This method is used to know whether Supplier Accept Expired Item. - JJ
 /// </summary>
 /// <param name="SupplierId"> id of supplier</param>
 /// <returns>object of SupplierProfileAC</returns>
 public SupplierProfileAC DoesSupplierAcceptExpiredItem(int SupplierId)
 {
     if (_supplierProfileContext.Fetch(x => x.Id == SupplierId && !x.IsDeleted).ToList().Any())
     {
         var supplier          = _supplierProfileContext.FirstOrDefault(x => x.Id == SupplierId && !x.IsDeleted);
         var SupplierProfileAC = new SupplierProfileAC
         {
             IsAcceptReturnForExpiredItem = supplier.IsAcceptReturnForExpiredItem,
             IsActive = supplier.IsActive
         };
         return(SupplierProfileAC);
     }
     else
     {
         return(null);
     }
 }
Example #5
0
        /// <summary>
        /// This method is used to update supplier profile in database. - JJ
        /// </summary>
        /// <param name="supplierProfile"> object of SupplierProfileAC</param>
        /// <param name="companyId"></param>
        /// <returns>object of SupplierProfile</returns>
        public SupplierProfile UpdateSupplier(SupplierProfileAC supplierProfile, int companyId)
        {
            try
            {
                var supplier = _supplierProfileContext.GetById(supplierProfile.Id);
                supplier.Code           = supplierProfile.Code;
                supplier.NameEn         = supplierProfile.NameEn;
                supplier.NameSl         = supplierProfile.NameSl;
                supplier.AddressEn      = supplierProfile.AddressEn;
                supplier.AddressSl      = supplierProfile.AddressSl;
                supplier.Phone          = supplierProfile.Phone;
                supplier.Fax            = supplierProfile.Fax;
                supplier.Email          = supplierProfile.Email;
                supplier.ZipCode        = supplierProfile.ZipCode;
                supplier.POBox          = supplierProfile.POBox;
                supplier.SupplierTypeId = supplierProfile.SupplierTypeId;
                supplier.TotalDaysLimit = supplierProfile.TotalDaysLimit;
                supplier.IsDeleted      = supplierProfile.IsDeleted;
                supplier.IsActive       = supplierProfile.IsActive;
                supplier.IsAcceptReturnForExpiredItem = supplierProfile.IsAcceptReturnForExpiredItem;
                supplier.CreatedDateTime  = supplierProfile.CreatedDateTime;
                supplier.ModifiedDateTime = DateTime.UtcNow;
                _supplierProfileContext.Update(supplier);
                _supplierProfileContext.SaveChanges();

                DeleteSupplierDaysLimit(supplierProfile.Id);

                if (supplier.SupplierType.ValueEn == StringConstants.Credit && supplier.TotalDaysLimit > 0)
                {
                    AddDaysLimit(supplierProfile.DiscountDays, supplier.Id, supplierProfile.Discount, supplierProfile.Days);
                }
                return(supplier);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
 public IHttpActionResult UpdateSupplierProfile(SupplierProfileAC supplier)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             if (MerchantContext.Permission.IsAllowToEditSupplierProfile)
             {
                 if (_supplierProfileContext.CheckSupplierPhoneIdExist(supplier.Phone, supplier.Id))
                 {
                     supplier.Phone = "";
                     return(Ok(new { supplier }));
                 }
                 else if (_supplierProfileContext.CheckSupplierEmailIdExist(supplier.Email, supplier.Id))
                 {
                     supplier.Email = "";
                     return(Ok(new { supplier }));
                 }
                 var     supplierProfile = _supplierProfileContext.UpdateSupplier(supplier, companyId);
                 Ledgers supplierLedgers = _iLedgerAccountRepository.GerLedgersBySupplierId(companyId, supplier.Id);
                 if (supplierLedgers == null)
                 {
                     Ledgers ledgers = new Ledgers();
                     ledgers.Address         = supplierProfile.AddressEn;
                     ledgers.State           = "Gujarat";
                     ledgers.CompanyId       = MerchantContext.CompanyDetails.Id;
                     ledgers.LedgerName      = supplierProfile.NameEn + "Ledgers";
                     ledgers.Name            = ledgers.LedgerName;
                     ledgers.CreatedDateTime = DateTime.UtcNow;
                     ledgers.GroupId         = 6;
                     ledgers.ParentLedgerId  = null;
                     ledgers.Balance         = 0;
                     ledgers.SuplierId       = supplierProfile.Id;
                     _iAccountingRepository.AddAccountLedger(ledgers);
                 }
                 return(Ok(supplierProfile));
             }
             else
             {
                 return(Ok(new { status = StringConstants.PermissionDenied }));
             }
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (PhoneNumberIsAlreadyExists)
     {
         return(BadRequest("PhoneNumberIsAlreadyExists"));
     }
     catch (EmailisAlreadyExists)
     {
         return(BadRequest("EmailisAlreadyExists"));
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }