Exemplo n.º 1
0
 public IHttpActionResult UpdateSupplierPersonalDetails(UpdateSupplierPersonalDetailsViewModel supplier)
 {
     try
     {
         string errorMessege = string.Empty;
         if (ModelState.IsValid)
         {
             List <string> properties = new List <string>();
             properties.Add("RegNo");
             properties.Add("FullName");
             properties.Add("Address");
             properties.Add("ContactNo");
             properties.Add("NICNo");
             _supplier.UpdateSupplierDetails(supplier, properties, true, out errorMessege);
         }
         else
         {
             errorMessege = ReadOnlyValue.GeneralError;
         }
         var messageData = new
         {
             code    = String.IsNullOrEmpty(errorMessege) ? ReadOnlyValue.SuccessMessageCode : ReadOnlyValue.ErrorMessageCode,
             message = String.IsNullOrEmpty(errorMessege) ? ReadOnlyValue.MessageSuccess : errorMessege
         };
         var returnObject = new { messageCode = messageData };
         return(Ok(returnObject));
     }
     catch (Exception ex)
     {
         string errorLogId   = _eventLogService.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name);
         var    messageData  = new { code = ReadOnlyValue.ErrorMessageCode, message = String.Format(ReadOnlyValue.MessageTaskmateError, errorLogId) };
         var    returnObject = new { messageCode = messageData };
         return(Ok(returnObject));
     }
 }
Exemplo n.º 2
0
        public virtual void UpdateSupplierDetails(UpdateSupplierPersonalDetailsViewModel entity, List <string> properties, bool isIncluded, out string errorMessege)
        {
            try
            {
                using (var dbContextTransaction = _supplierRepository.DbContext.Database.BeginTransaction())
                {
                    try
                    {
                        Supplier supplier = new Supplier();

                        supplier              = _supplierRepository.Get(x => x.RegNo == entity.registrationNo).FirstOrDefault();
                        supplier.RegNo        = entity.registrationNo;
                        supplier.FullName     = entity.fullName;
                        supplier.Address      = entity.address;
                        supplier.ContactNo    = entity.contactNumber;
                        supplier.NICNo        = entity.nicNo;
                        supplier.CreatedDate  = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById(ConfigurationManager.AppSettings["LocalTimeZone"]));
                        supplier.CreatedBy    = "admin";//User.Identity.Name;
                        supplier.ModifiedBy   = "admin";
                        supplier.ModifiedDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById(ConfigurationManager.AppSettings["LocalTimeZone"]));

                        base.Update(supplier, properties, isIncluded);

                        properties.Clear();
                        properties.Add("Name");

                        Route route = new Route();
                        route      = supplier.Route;
                        route.Name = entity.routes.name;
                        _routeRepository.Update(route, properties, true);

                        properties.Clear();
                        properties.Add("Name");
                        SupplierType suppliertype = new SupplierType();
                        suppliertype      = supplier.SupplierType;
                        suppliertype.Name = entity.types.name;
                        _supplierTypeRepository.Update(suppliertype, properties, true);
                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                        throw ex;
                    }
                }

                errorMessege = String.Empty;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }