コード例 #1
0
        public BaseResponse <bool> SetActiveYacht(int yachtId, bool isActiveOperation)
        {
            try
            {
                bool check = ActiveYacht(yachtId).IsSuccessStatusCode;
                if (check)
                {
                    var entity = _context.Yachts.FirstOrDefault(x => x.Id == yachtId && !x.Deleted && x.ActiveForOperation != isActiveOperation);
                    if (entity == null)
                    {
                        return(BaseResponse <bool> .BadRequest(false));
                    }
                    entity.ActiveForOperation = isActiveOperation;
                    entity.LastModifiedBy     = GetUserGuidId();
                    entity.LastModifiedDate   = DateTime.Now;
                    _context.Yachts.Update(entity);
                    var result = _context.SaveChanges();
                    return(result == 1 ? BaseResponse <bool> .Success(true) : BaseResponse <bool> .BadRequest(false));
                }

                return(BaseResponse <bool> .Success());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #2
0
 //Update list Attribute values if existed or create new if not existed
 public BaseResponse <bool> Synchronize(List <YachtTourAttributeValueUpdateModel> models)
 {
     try
     {
         var listForCreate = new List <YachtTourAttributeValueCreateModel>();
         var listForUpdate = new List <YachtTourAttributeValueUpdateModel>();
         foreach (var item in models)
         {
             var tourId = item.YachtTourFid.Decrypt().ToInt32();
             var entity = _db.YachtTourAttributeValues.AsNoTracking().FirstOrDefault(k => k.YachtTourFid == tourId && k.AttributeFid == item.AttributeFid);
             if (entity != null)
             {
                 listForUpdate.Add(item);
             }
             else
             {
                 var createModel = new YachtTourAttributeValueCreateModel();
                 createModel.InjectFrom(item);
                 listForCreate.Add(createModel);
             }
         }
         var createResult = Create(listForCreate);
         var updateResult = Update(listForUpdate);
         if (createResult.IsSuccessStatusCode && updateResult.IsSuccessStatusCode)
         {
             return(BaseResponse <bool> .Success(true));
         }
         return(BaseResponse <bool> .BadRequest());
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
コード例 #3
0
        public BaseResponse <bool> Update(List <YachtTourAttributeValueUpdateModel> models, bool disableSaveChange = false)
        {
            try
            {
                if (models.Count == 0)
                {
                    return(BaseResponse <bool> .Success(true));
                }
                foreach (var item in models)
                {
                    var tourId = item.YachtTourFid.Decrypt().ToInt32();
                    var entity = _db.YachtTourAttributeValues.FirstOrDefault(k => k.YachtTourFid == tourId && k.AttributeFid == item.AttributeFid);
                    if (entity != null)
                    {
                        entity = GenerateForUpdate(entity);
                        entity.AttributeValue = item.AttributeValue;
                        _db.YachtTourAttributeValues.Update(entity);
                    }
                }
                //return without save change
                if (disableSaveChange)
                {
                    return(BaseResponse <bool> .Success(true));
                }

                var result = _db.SaveChanges();
                return(result > 0
                    ? BaseResponse <bool> .Success(true)
                    : BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #4
0
        public BaseResponse <CheckHealthModel> ServerInfo()
        {
            var model = new CheckHealthModel();

            try
            {
                //Info
                model.ServerName       = ApiUrlHelper.ServerName;
                model.Enviroment       = ApiUrlHelper.Server;
                model.IdentityApi      = ApiUrlHelper.IdentityApiUrl;
                model.FileStreamApi    = ApiUrlHelper.FileStreamApiUrl;
                model.AdminApi         = ApiUrlHelper.AdminApiUrl;
                model.ConfigurationApi = ApiUrlHelper.ConfigurationApi;
                model.ConnectionString = GetConnectionStringPublicInfo(ApiUrlHelper.ConnectionString);

                //Test Connection
                var testConnect_Database = TestConnectDatabase();
                model.TestConnect_Database = testConnect_Database ? "Connect database successful" : "Connect database failed";
                if (testConnect_Database)
                {
                    model.IsGoodHealth = true;
                    return(BaseResponse <CheckHealthModel> .Success(model));
                }

                return(BaseResponse <CheckHealthModel> .BadRequest(model));
            }
            catch (Exception ex)
            {
                return(BaseResponse <CheckHealthModel> .InternalServerError(model));
            }
        }
コード例 #5
0
        public async Task <BaseResponse <bool> > CreateRangeAsync(List <HotelAttributeValueCreateModels> model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var createItems = new List <HotelAttributeValues>();
                foreach (var item in model)
                {
                    var createItem = new HotelAttributeValues();
                    createItem.InjectFrom(item);
                    createItem.BasedAffective   = false;
                    createItem.LastModifiedBy   = GetUserGuidId();
                    createItem.LastModifiedDate = DateTime.UtcNow;
                    createItems.Add(createItem);
                }
                if (createItems.Count() > 0)
                {
                    await _db.HotelAttributeValues.AddRangeAsync(createItems);

                    await _db.SaveChangesAsync();

                    return(BaseResponse <bool> .Success(true));
                }
                return(BaseResponse <bool> .BadRequest(false));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #6
0
        public BaseResponse <bool> DeleteServiceControl(int AdditionalServiceId, int YachtId)
        {
            using (var tran = _context.Database.BeginTransaction())
            {
                try
                {
                    var entity = _context.YachtAdditionalServiceControls.FirstOrDefault(x => x.AdditionalServiceFid == AdditionalServiceId && x.YachtFid == YachtId && !x.Deleted);
                    if (entity == null)
                    {
                        return(BaseResponse <bool> .BadRequest());
                    }

                    entity.Deleted          = true;
                    entity.LastModifiedBy   = GetUserGuidId();
                    entity.LastModifiedDate = DateTime.Now;
                    _context.YachtAdditionalServiceControls.Update(entity);

                    _context.SaveChangesAsync().Wait();
                    tran.Commit();
                    return(BaseResponse <bool> .Success());
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    return(BaseResponse <bool> .BadRequest());
                }
            }
        }
コード例 #7
0
        public BaseResponse <string> Create(string token, string returnUrl)
        {
            try
            {
                if (string.IsNullOrEmpty(token) || JwtTokenHelper.DecodeJwtToken(token) == null)
                {
                    return(BaseResponse <string> .BadRequest());
                }

                var authModel = JwtTokenHelper.DecodeJwtToken(token);
                var userToken = new UserTokens()
                {
                    Id          = UniqueIDHelper.GenarateRandomString(12),
                    UserFid     = Guid.Parse(authModel.UserId),
                    AccessToken = token,
                    ReturnUrl   = returnUrl,
                };
                _db.UserTokens.Add(userToken);
                if (_db.SaveChanges() > 0)
                {
                    return(BaseResponse <string> .Success(userToken.Id));
                }
                return(BaseResponse <string> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <string> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #8
0
        public BaseResponse <PagedList <YachtTourNonOperationDayViewModel> > FindByTourFid(int tourId, YachtTourNonOperationDaySearchModel searchModel)
        {
            try
            {
                var query = _db.YachtTourNonOperationDays
                            .AsNoTracking()
                            .Where(k => !k.Deleted && k.YachtTourFid == tourId)
                            .Select(k => _mapper.Map <YachtTourNonOperationDays, YachtTourNonOperationDayViewModel>(k));
                var totlaItems = query.Count();

                var queryData = query.Skip(searchModel.PageSize * (searchModel.PageIndex - 1))
                                .Take(searchModel.PageSize)
                                .ToList();

                if (queryData != null)
                {
                    var data      = queryData.Select(k => LoadYachtName(k)).ToList();
                    var pagedList = new PagedList <YachtTourNonOperationDayViewModel>(data, totlaItems, searchModel.PageIndex, searchModel.PageSize);
                    return(BaseResponse <PagedList <YachtTourNonOperationDayViewModel> > .Success(pagedList));
                }

                return(BaseResponse <PagedList <YachtTourNonOperationDayViewModel> > .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <PagedList <YachtTourNonOperationDayViewModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #9
0
        public async Task <IActionResult> CreateRangeAsync([FromBody] HotelAttributeValueCreateModel model)
        {
            string[] arrAttributeFid    = model.AttributeFid.Split(",");
            string[] arrAttributeValues = model.AttributeValue.Split(",");

            if (arrAttributeFid.Length > 0 && arrAttributeValues.Length > 0)
            {
                var lstattributeValue = new List <HotelAttributeValueCreateModels>();
                for (int i = 0; i < arrAttributeFid.Length; i++)
                {
                    var attributeValue = new HotelAttributeValueCreateModels();
                    attributeValue.HotelFid             = model.HotelFid;
                    attributeValue.AttributeCategoryFid = model.AttributeCategoryFid;
                    attributeValue.AttributeFid         = arrAttributeFid[i].ToInt32();
                    attributeValue.AttributeValue       = arrAttributeValues[i];
                    attributeValue.EffectiveDate        = model.EffectiveDate;
                    lstattributeValue.Add(attributeValue);
                }
                if (lstattributeValue.Count > 0)
                {
                    var response = await _hotelAttributeValueService.CreateRangeAsync(lstattributeValue);

                    if (response.IsSuccessStatusCode)
                    {
                        return(Ok(response));
                    }
                }
            }
            return(Ok(BaseResponse <bool> .BadRequest()));
        }
コード例 #10
0
        public BaseResponse <bool> Delete(int id)
        {
            try
            {
                var res = _context.YachtInformations.FirstOrDefault(r => r.Deleted == false && r.Id == id);
                if (res == null)
                {
                    return(BaseResponse <bool> .NoContent(false));
                }

                res.Deleted          = true;
                res.LastModifiedBy   = GetUserGuidId();
                res.LastModifiedDate = DateTime.Now;
                var activeResult = _context.SaveChanges();
                if (activeResult == 1)
                {
                    return(BaseResponse <bool> .Success(true));
                }

                return(BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #11
0
        public BaseResponse <bool> IsActivated(int id, bool value)
        {
            try
            {
                var entity = _context.YachtInformations.FirstOrDefault(x => x.Id == id && x.Deleted == false && x.IsActivated != value);
                if (entity == null)
                {
                    return(BaseResponse <bool> .NotFound(false));
                }

                var isSingleInfo = !_context.YachtInformations.
                                   Any(r => r.Deleted == false && r.IsActivated == true &&
                                       r.YachtFid == entity.YachtFid && r.Id != entity.Id);

                if (isSingleInfo)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                entity.IsActivated      = value;
                entity.LastModifiedBy   = GetUserGuidId();
                entity.LastModifiedDate = DateTime.Now;
                _context.SaveChanges();
                return(BaseResponse <bool> .Success());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #12
0
        public BaseResponse <bool> IsActivated(int id, bool value)
        {
            try
            {
                var check = _db.YachtTourInformations.Any(x => x.Id == id && !x.Deleted && x.IsActivated == value);
                if (check)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var entity = _db.YachtTourInformations.FirstOrDefault(x => x.Id == id && x.Deleted == false);
                if (entity == null)
                {
                    return(BaseResponse <bool> .NotFound());
                }

                entity.IsActivated      = value;
                entity.LastModifiedBy   = _userId;
                entity.LastModifiedDate = DateTime.Now;
                _db.SaveChanges();
                return(BaseResponse <bool> .Success());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #13
0
        public BaseResponse <bool> Update(HotelUpdateModel model)
        {
            try
            {
                //Return badRequest if model null
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var hotel = _db.Hotels.FirstOrDefault(k => k.Id == model.Id && !k.Deleted);
                if (hotel == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                //Update hotel
                hotel.InjectFrom(model);
                hotel.LastModifiedDate = DateTime.Now.Date;
                hotel.LastModifiedBy   = UserContextHelper.UserId;
                _db.Hotels.Update(hotel);
                _db.SaveChanges();
                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(ex));
            }
        }
コード例 #14
0
 public BaseResponse <YachtNonBusinessDayViewModel> GetYactNonBusinessDayById(int id)
 {
     try
     {
         var result = _context.YachtNonOperationDays.AsNoTracking().FirstOrDefault(p => p.Id == id && p.Deleted == false);
         if (result != null)
         {
             var model = new YachtNonBusinessDayViewModel()
             {
                 Id        = result.Id,
                 YachtFid  = result.YachtFid,
                 EndDate   = result.EndDate.Date,
                 Recurring = result.Recurring,
                 StartDate = result.StartDate.Date,
                 Remark    = result.Remark,
             };
             return(BaseResponse <YachtNonBusinessDayViewModel> .Success(model));
         }
         else
         {
             return(BaseResponse <YachtNonBusinessDayViewModel> .BadRequest());
         }
     }
     catch (Exception ex)
     {
         return(BaseResponse <YachtNonBusinessDayViewModel> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
コード例 #15
0
        public BaseResponse <bool> IsActivated(int id, bool value)
        {
            try
            {
                var entity = _context.YachtAdditionalServices.FirstOrDefault(x => x.Id == id && x.Deleted == false);
                if (entity == null)
                {
                    return(BaseResponse <bool> .NotFound());
                }
                var isSingleInfo = !_context.YachtAdditionalServices.
                                   Any(r => r.Deleted == false && r.IsActive == true &&
                                       r.Id != entity.Id && r.MerchantFid == entity.MerchantFid);

                if (isSingleInfo)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                entity.IsActive         = value;
                entity.LastModifiedBy   = GetUserGuidId();
                entity.LastModifiedDate = DateTime.Now;
                _context.SaveChanges();
                return(BaseResponse <bool> .Success());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .BadRequest());
            }
        }
コード例 #16
0
        public BaseResponse <bool> Create(YachtTourExternalRefLinkModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                bool checkLink           = IsUrlValid(model.UrlLink);
                var  pricingTypeResponse = _commonValueRequestService
                                           .GetCommonValueByGroupInt(CommonValueGroupConstant.ExternalRefLinkType, model.LinkTypeFid);

                var entity = new YachtTourExternalRefLinks();
                entity.InjectFrom(model);
                entity.UrlLink          = checkLink == true ? model.UrlLink : null;
                entity.YachtTourFid     = int.Parse(Terminator.Decrypt(model.YachtTourFid));
                entity.LinkTypeResKey   = pricingTypeResponse.IsSuccessStatusCode ? pricingTypeResponse.ResponseData.ResourceKey : string.Empty;
                entity.Deleted          = false;
                entity.CreatedDate      = DateTime.Now;
                entity.CreatedBy        = UserContextHelper.UserId;
                entity.LastModifiedDate = DateTime.Now;
                entity.LastModifiedBy   = UserContextHelper.UserId;
                _db.YachtTourExternalRefLinks.Add(entity);
                _db.SaveChangesAsync().Wait();
                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #17
0
        public BaseResponse <bool> UpdateServiceDetail(YachtAdditionalServiceDetailViewModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var entity = _context.YachtAdditionalServiceDetails.FirstOrDefault(x => x.AdditionalServiceFid == model.AdditionalServiceFid && x.ProductFid == model.ProductFid);
                if (entity == null)
                {
                    return(BaseResponse <bool> .NotFound());
                }
                var check = CheckDate(model.EffectiveDate, model.EffectiveEndDate);
                if (check)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                entity.Remark           = model.Remark;
                entity.EffectiveEndDate = model.EffectiveEndDate;
                entity.LastModifiedBy   = GetUserGuidId();
                entity.LastModifiedDate = DateTime.Now;

                _context.YachtAdditionalServiceDetails.Update(entity);
                _context.SaveChangesAsync().Wait();
                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #18
0
        public async Task <BaseResponse <bool> > UpdateReservationProcessingFees(HotelReservationProcessingFeeUpdateModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                var entity = _db.HotelReservationProcessingFees.Find(model.ReservationsFid);
                if (entity != null)
                {
                    entity.InjectFrom(model);
                    entity.LastModifiedBy   = GetUserGuidId();
                    entity.LastModifiedDate = DateTime.Now;

                    _db.HotelReservationProcessingFees.Update(entity);
                    await _db.SaveChangesAsync();

                    return(BaseResponse <bool> .Success(true));
                }
                return(BaseResponse <bool> .NotFound(false));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message));
            }
        }
コード例 #19
0
 public BaseResponse <bool> CreateAdditionalServiceControl(YachtAdditionalServiceControlCreateModel model)
 {
     try
     {
         if (model == null)
         {
             return(BaseResponse <bool> .BadRequest());
         }
         var check = CheckDate(model.EffectiveDate, model.EffectiveEndDate);
         if (check)
         {
             return(BaseResponse <bool> .BadRequest());
         }
         var entity = new YachtAdditionalServiceControls();
         entity.InjectFrom(model);
         entity.CreatedDate      = DateTime.Now;
         entity.CreatedBy        = GetUserGuidId();
         entity.LastModifiedDate = DateTime.Now;
         entity.LastModifiedBy   = GetUserGuidId();
         _context.YachtAdditionalServiceControls.Add(entity);
         _context.SaveChangesAsync().Wait();
         return(BaseResponse <bool> .Success(true));
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
コード例 #20
0
        public async Task <BaseResponse <bool> > CreateReservationProcessingFees(HotelReservationProcessingFeeCreateModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                var checkExistEntity = _db.HotelReservationProcessingFees.Find(model.ReservationsFid);
                if (checkExistEntity == null)
                {
                    var entity = new HotelReservationProcessingFees();
                    entity.InjectFrom(model);
                    entity.GeneratedDate    = DateTime.Now;
                    entity.LastModifiedBy   = GetUserGuidId();
                    entity.LastModifiedDate = DateTime.Now;

                    await _db.HotelReservationProcessingFees.AddAsync(entity);

                    await _db.SaveChangesAsync();

                    return(BaseResponse <bool> .Success(true));
                }
                return(BaseResponse <bool> .NotFound(message : "Duplicated"));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message));
            }
        }
コード例 #21
0
        public BaseResponse <bool> DeleteUserTokenByUserId(string uid)
        {
            try
            {
                if (string.IsNullOrEmpty(uid))
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var entities = _db.UserTokens.AsNoTracking().Where(k => k.UserFid.ToString().ToUpper() == uid.ToUpper()).ToList();
                if (entities != null)
                {
                    _db.UserTokens.RemoveRange(entities);
                    if (_db.SaveChanges() > 0)
                    {
                        return(BaseResponse <bool> .Success(true));
                    }
                }

                return(BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #22
0
        public async Task <BaseResponse <bool> > CreateAsync(HotelAttributeCreateModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var createItem = new HotelAttributes();
                createItem.InjectFrom(model);
                createItem.UniqueId         = UniqueIDHelper.GenarateRandomString(12);
                createItem.Deleted          = false;
                createItem.UniqueId         = UniqueIDHelper.GenarateRandomString(12);
                createItem.CreatedBy        = GetUserGuidId();
                createItem.CreatedDate      = DateTime.UtcNow;
                createItem.LastModifiedBy   = GetUserGuidId();
                createItem.LastModifiedDate = DateTime.UtcNow;
                await _db.HotelAttributes.AddAsync(createItem);

                await _db.SaveChangesAsync();

                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #23
0
ファイル: SignInService.cs プロジェクト: war-man/AQ_Project
        public BaseResponse <bool> IsAllowedToken(string token)
        {
            try
            {
                if (string.IsNullOrEmpty(token))
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                var authModel = JwtTokenHelper.DecodeJwtToken(token);
                if (authModel != null)
                {
                    var user = Find(authModel.Email);
                    if (user != null)
                    {
                        var tokenEffectiveDate = long.Parse(authModel.TokenEffectiveTimeStick);
                        var userEffectiveDate  = user.TokenEffectiveTimeStick;
                        if (tokenEffectiveDate > userEffectiveDate)
                        {
                            return(BaseResponse <bool> .Success(true));
                        }
                        return(BaseResponse <bool> .BadRequest(message : "Token is not allowed because user was signed out."));
                    }
                }

                return(BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #24
0
        public async Task <BaseResponse <bool> > UpdateAsync(HotelAttributeUpdateModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var entity = _db.HotelAttributes.AsNoTracking().FirstOrDefault(k => k.Deleted == false && k.Id == model.Id);

                if (entity != null)
                {
                    entity.AttributeCategoryFid = model.AttributeCategoryFid;
                    entity.AttributeName        = model.AttributeName;
                    entity.ResourceKey          = model.ResourceKey;
                    entity.IconCssClass         = model.IconCssClass;
                    entity.Remarks          = model.Remarks;
                    entity.IsDefault        = model.IsDefault;
                    entity.OrderBy          = model.OrderBy;
                    entity.LastModifiedBy   = GetUserGuidId();
                    entity.LastModifiedDate = DateTime.UtcNow;
                    int checkResult = await _db.SaveChangesAsync();

                    return(BaseResponse <bool> .Success(true));
                }
                return(BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #25
0
        public BaseResponse <bool> DeleteYachtPricingPlans(int Id)
        {
            try
            {
                if (Id == 0 && Id < 0)
                {
                    return(BaseResponse <bool> .BadRequest(false));
                }

                YachtPricingPlanViewModel yachtPricingView  = new YachtPricingPlanViewModel();
                YachtPricingPlans         yachtPricingPlans = _context.YachtPricingPlans.AsNoTracking().FirstOrDefault(x => x.Id == Id);
                yachtPricingPlans.Deleted = true;
                _context.Update(yachtPricingPlans);
                _context.SaveChanges();
                List <YachtPricingPlanDetails> yachtPricingPlanDetails = _context.YachtPricingPlanDetails.AsNoTracking().Where(x => x.PricingPlanFid == yachtPricingPlans.Id).ToList();
                foreach (var item in yachtPricingPlanDetails)
                {
                    item.Deleted = true;
                    _context.Update(item);
                    _context.SaveChanges();
                }
                YachtPricingPlanInformations yachtPricingPlanInfo = _context.YachtPricingPlanInformations.AsNoTracking().FirstOrDefault(x => x.PricingPlanFid == yachtPricingPlans.Id);
                yachtPricingPlanInfo.Deleted = true;
                _context.Update(yachtPricingPlanInfo);
                _context.SaveChanges();
                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #26
0
        public async Task <BaseResponse <bool> > SingleSignInAsync(HttpContext httpContext, AuthenticateViewModel model, string authenticationScheme = "", AuthenticationProperties authenticationProperties = null)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                authenticationScheme     = (string.IsNullOrEmpty(authenticationScheme)) ? SSOAuthenticationScheme : authenticationScheme;
                authenticationProperties = authenticationProperties == null ? new AuthenticationProperties
                {
                    IsPersistent = true,
                    ExpiresUtc   = DateTimeOffset.UtcNow.AddDays(365)
                } : authenticationProperties;
                var claims         = JwtTokenHelper.GetUserClaims(model);
                var claimsIdentity = new ClaimsIdentity(claims, authenticationScheme);
                var user           = new ClaimsPrincipal(claimsIdentity);
                await httpContext.SignInAsync(authenticationScheme, user, authenticationProperties);

                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .InternalServerError(message : e.Message, fullMsg : e.StackTrace));
            }
        }
コード例 #27
0
        public BaseResponse <bool> Create(List <YachtTourAttributeValueCreateModel> models, bool disableSaveChange = false)
        {
            try
            {
                if (models.Count == 0)
                {
                    return(BaseResponse <bool> .Success(true));
                }
                var entities = models
                               .Select(k => GenerateForCreate(k))
                               .ToList();
                _db.YachtTourAttributeValues.AddRange(entities);

                //return without save change
                if (disableSaveChange)
                {
                    return(BaseResponse <bool> .Success(true));
                }

                var resul = _db.SaveChanges();
                return(resul > 0
                        ? BaseResponse <bool> .Success(true)
                        : BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #28
0
        public BaseResponse <bool> Create(YachAdditionalServiceUpdateModel createModel)
        {
            try
            {
                if (createModel == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }
                var check = CheckDate(createModel.ActiveFrom, createModel.ActiveTo);
                if (check)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                var entity = DefaultYachtAdditionalServices();
                entity.InjectFrom(createModel);
                entity.CreatedBy        = GetUserGuidId();
                entity.CreatedDate      = DateTime.Now;
                entity.LastModifiedBy   = GetUserGuidId();
                entity.LastModifiedDate = DateTime.Now;
                _context.YachtAdditionalServices.Add(entity);
                _context.SaveChangesAsync().Wait();
                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
コード例 #29
0
 public BaseResponse <bool> CreateProductSupplier(YachtMerchantProductSupplierViewModel model)
 {
     try
     {
         if (model.EffectiveEndDate.HasValue && model.EffectiveEndDate.Value.Date < model.EffectiveDate.Date)
         {
             return(BaseResponse <bool> .BadRequest(false));
         }
         var entity = new YachtMerchantProductSuppliers();
         entity.ProductFid       = model.ProductFid;
         entity.VendorFid        = model.VendorFid;
         entity.EffectiveDate    = model.EffectiveDate;
         entity.EffectiveEndDate = model.EffectiveEndDate;
         entity.Remark           = model.Remark;
         entity.Deleted          = false;
         entity.CreatedBy        = GetUserGuidId();
         entity.CreatedDate      = DateTime.Now;
         entity.LastModifiedDate = DateTime.Now;
         entity.LastModifiedBy   = GetUserGuidId();
         _context.YachtMerchantProductSuppliers.Add(entity);
         _context.SaveChangesAsync().Wait();
         return(BaseResponse <bool> .Success(true));
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
コード例 #30
0
        public BaseResponse <YachtCheckActiveModel> ActiveYacht(int yachtId)
        {
            try
            {
                var yacht = _context.Yachts.FirstOrDefault(x => x.Id == yachtId && !x.Deleted);
                if (yacht == null)
                {
                    return(BaseResponse <YachtCheckActiveModel> .BadRequest());
                }

                var infor       = _context.YachtInformations.Any(x => x.YachtFid == yachtId && !x.Deleted && x.IsActivated == true);
                var pricingPlan = _context.YachtPricingPlans.Any(x => x.YachtFid == yachtId && !x.Deleted && x.IsActivated == true);
                var refImage    = _context.YachtFileStreams.Any(x => x.YachtFid == yachtId && !x.Deleted &&
                                                                x.FileTypeFid == (int)YachtImageTypeEnum.RefImage &&
                                                                x.ActivatedDate.Date <= DateTime.Now.Date);

                var model = new YachtCheckActiveModel()
                {
                    CheckInformation        = infor,
                    CheckRefImage           = refImage,
                    CheckPricingPlan        = pricingPlan,
                    CheckActiveForOperation = yacht.ActiveForOperation,
                };
                if (infor && pricingPlan && refImage)
                {
                    model.Allow = true;
                }

                return(BaseResponse <YachtCheckActiveModel> .Success(model));
            }
            catch (Exception ex)
            {
                return(BaseResponse <YachtCheckActiveModel> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }