Ejemplo n.º 1
0
 public IActionResult CreateYachtMerchant([FromBody] YachtMerchantCreateModel createModel)
 {
     try
     {
         var result = _yachtMerchantService.CreateYachtMerchant(createModel);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.StackTrace.ToString()));
     }
 }
Ejemplo n.º 2
0
        public bool CreateYachtMerchant(YachtMerchantCreateModel model)
        {
            using (var trans = _dbYachtContext.Database.BeginTransaction())
            {
                try
                {
                    var userGuid   = _workContext.UserGuid;
                    var userRoleId = _workContext.UserRoleId;
                    var entity     = _mapper.Map <YachtMerchants>(model);

                    entity.UniqueId         = UniqueIDHelper.GenerateRandomString(12, false);
                    entity.CreatedBy        = userGuid;
                    entity.CreatedDate      = DateTime.Now;
                    entity.LastModifiedBy   = userGuid;
                    entity.LastModifiedDate = DateTime.Now;
                    _dbYachtContext.YachtMerchants.Add(entity);
                    _dbYachtContext.SaveChanges();

                    if (userRoleId == (int)UserRoleEnum.YachtMerchantManager)
                    {
                        var merchantAccountMgt = new YachtMerchantAqmgts
                        {
                            AqadminUserFid     = userGuid,
                            MerchantFid        = entity.Id,
                            MerchantName       = entity.MerchantName,
                            CreatedBy          = userGuid,
                            CreatedDate        = DateTime.Now,
                            EffectiveStartDate = DateTime.Now,
                            EffectiveEndDate   = DateTime.Now.AddYears(1),
                            Deleted            = false,
                            LastModifiedBy     = userGuid,
                            LastModifiedDate   = DateTime.Now
                        };
                        _dbYachtContext.YachtMerchantAqmgts.AddAsync(merchantAccountMgt);
                        _dbYachtContext.SaveChanges();
                    }

                    trans.Commit();
                    trans.Dispose();
                    return(true);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    trans.Dispose();
                    throw ex;
                }
            }
        }
Ejemplo n.º 3
0
 public bool UpdateYachtMerchantAsync(YachtMerchantCreateModel model)
 {
     try
     {
         var entity = _dbYachtContext.YachtMerchants.Where(x => x.Id == model.Id && x.Deleted == false).SingleOrDefault();
         entity = _mapper.Map <YachtMerchantCreateModel, YachtMerchants>(model, entity);
         entity.LastModifiedBy   = _workContext.UserGuid;
         entity.LastModifiedDate = DateTime.Now;
         _dbYachtContext.YachtMerchants.Update(entity);
         _dbYachtContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }