public IHttpActionResult CloseOrder(RentoRequest <OrderClose> request) { var response = new RentoResponse(request); return(Ok(TryCatch(request, response, ValidateType.Active, async() => { if ((!request.Data.Approve && !ValidateRequirdField(request.Data.Comment)) || !ValidateRequirdField(request.Data.Star) ) { response.ErrorCode = ErrorCode.RequirdField; return; } ; var userToken = await CarManager.CloseOrder(UserSession.Id, request.Data); if (userToken != null) { var bodyAr = request.Data.Approve ? "لقد تم الموافقة على طلبكم من قبل المكتب" : "لقد تم رفض طلبكم من قبل المكتب وذلك بسبب: " + request.Data.Comment; var bodyEn = request.Data.Approve ? "Your request has been processed successfully" : "Your request has been rejected from office and the reason is: " + request.Data.Comment; await Database.MessageManager.Create(userToken.CustomerId, string.Format("{0} {1}", request.Language == (int)Language.Arabic ? bodyAr + " ذو الرقم " : bodyEn + " with number ", request.Data.Id )); if (!string.IsNullOrEmpty(userToken.NotificationToken)) { FirebaseNotification.SendPushNotification("طلب استئجار السيارة", bodyAr, userToken.NotificationToken, userToken.IsAndroid); } } }))); }
public async Task <IHttpActionResult> AdminLogin(RentoRequest <AdminUserLogin> request) { Logger.Debug("AdminLogin", request); return(Ok(await TryCatchResponse(request, ValidateType.Operation, async(RentoResponse <UserLoginResponse> response) => { if (!ValidateRequirdField(request.Data.Password) || !ValidateRequirdField(request.Data.RequestUserId)) { response.ErrorCode = ErrorCode.RequirdField; return; } var userSession = await AccountManager.AdminLogin(UserSession.Id, request.Data); if (userSession == null) { response.ErrorCode = ErrorCode.UserDoesNotExist; return; } string token = GenerateToken(userSession.Username, userSession.Id, userSession.Type); response.Data = new UserLoginResponse() { Id = userSession.Id, Type = userSession.Type, Token = token, Username = userSession.Username }; }))); }
public async Task <IHttpActionResult> CreateMobileNotificationMultiple(RentoRequest <MobileMessage> request) { Logger.Debug("CreateMobileNotificationMultiple", request); return(Ok(await TryCatchSyncBase(request, ValidateType.Admin, (RentoResponse response) => { if (!ValidateRequirdField(request.Data.Body, request.Data.Title)) { response.ErrorCode = ErrorCode.RequirdField; return; } ; switch ((MobileType)request.Data.Type) { case MobileType.All: Helper.FirebaseNotification.SendPushNotification(request.Data.Title, request.Data.Body, "/topics/erentusers", true); Helper.FirebaseNotification.SendPushNotification(request.Data.Title, request.Data.Body, "/topics/erentusers", false); break; case MobileType.Android: Helper.FirebaseNotification.SendPushNotification(request.Data.Title, request.Data.Body, "/topics/erentusers", true); break; case MobileType.iPhone: Helper.FirebaseNotification.SendPushNotification(request.Data.Title, request.Data.Body, "/topics/erentusers", false); break; default: break; } }))); }
public IHttpActionResult Save(RentoRequest <Car> request) { var response = new RentoResponse <BaseEntity>(request); return(Ok(TryCatch(request, response, ValidateType.Active, async() => { List <RentoImage> tempImages = request.Data.Images; if (request.Data.Images != null && request.Data.Images.Count > 0) { foreach (var image in request.Data.Images) { if (!Rento.Helper.FileExtension.ScanImage(image.Content)) { response.ErrorCode = ErrorCode.InvalidImageFormat; return; } } request.Data.Images = null; } Logger.Debug("Car - Save", request); request.Data.Images = tempImages; tempImages = null; response.Data = await CarManager.Save(UserSession.Id, request.Data); }))); }
public async Task <IHttpActionResult> List(RentoRequest request) { return(Ok(await TryCatchResponse(request, ValidateType.Active, async(RentoResponse <List <CarActionBaseInfo> > response) => { response.Data = await CarManager.ListRequest(UserSession.Id, true); }))); }
public async Task <IHttpActionResult> RefreshToken(RentoRequest <TokenRefresh> request) { return(Ok(await TryCatchResponseBase(request, ValidateType.None, async(RentoResponse response) => { await AccountManager.RefreshToken(request.Data); }))); }
public async Task <IHttpActionResult> ForgetPassword(RentoRequest <string> request) { Logger.Debug("ForgetPassword", request.Data); return(Ok(await TryCatchResponse(request, ValidateType.None, async(RentoResponse <string> response) => { if (!ValidateRequirdField(request.Data)) { response.ErrorCode = ErrorCode.RequirdField; return; } var forgetPassword = await Database.AccountManager.SelectMobile(request.Data); if (forgetPassword != null) { var code = StringHelper.GenerateRandomNumber(6); RunActionAsync(() => { SMSMessage.Send(forgetPassword.Mobile, code.ToString()); }); RentoCache.Set(FORGET_PASSWORD_KEY + forgetPassword.Token, new ForgetPasswordCacheObject() { Code = code, UserId = forgetPassword.UserId }, 1); response.Data = forgetPassword.Token.ToString(); } }))); }
public async Task <IHttpActionResult> ChangePassword(RentoRequest <ChangePassword> request) { request.Data.NewPassword = request.Data.NewPassword.ToSafe(); request.Data.OldPassword = request.Data.OldPassword; Logger.Debug("Change Password", request); return(Ok(await TryCatchResponseBase(request, ValidateType.Active, async(RentoResponse response) => { if (!ValidateRequirdField(request.Data.OldPassword, request.Data.NewPassword)) { response.ErrorCode = ErrorCode.RequirdField; return; } ; if (!request.Data.NewPassword.CheckRegexValid(Constant.PASSWORD_EXPRESION)) { response.ErrorCode = ErrorCode.InvalidPasswordFormat; return; } ; var success = await Database.AccountManager.ChangePassword(UserSession.Id, request.Data); if (!success) { response.ErrorCode = ErrorCode.OldPasswordNotMatch; } }))); }
public async Task <IHttpActionResult> ResetPassword(RentoRequest <ResetPassword> request) { Logger.Debug("ResetPassword", request.Data); return(Ok(await TryCatchResponseBase(request, ValidateType.None, async(RentoResponse response) => { if (!ValidateRequirdField(request.Data.Code) || !ValidateRequirdField(request.Data.NewPassword)) { response.ErrorCode = ErrorCode.RequirdField; return; } var cacheReponse = RentoCache.Get <ForgetPasswordCacheObject>(FORGET_PASSWORD_KEY + request.Token); if (cacheReponse != null) { if (request.Data.Code.Equals(cacheReponse.Code)) { await Database.AccountManager.ResetPassword(cacheReponse.UserId, request.Data.NewPassword); } else { response.ErrorCode = ErrorCode.InvalidCode; } } else { response.ErrorCode = ErrorCode.UserDoesNotExist; } }))); }
public ActionResult ContactPost(Contact model) { var success = false; try { var bodyHtml = Rento.Helper.EmailMessage.BuildBodyHTML(model.Subject, model.Email, model.Mobile, model.Name, model.Body); success = Rento.Helper.EmailMessage.SendEmail(model.Email, "*****@*****.**", "E-Rent Contact Message", bodyHtml); } catch (Exception e) { Logger.Exception(e); } var request = new RentoRequest() { Language = Shared.FixData.IsRTL ? (int)Language.Arabic : (int)Language.English }; if (success) { return(RentoJson(new RentoResponse(request))); } return(RentoJson(new RentoResponse(request) { ErrorCode = ErrorCode.GeneralError })); }
public async Task <IHttpActionResult> Verification(RentoRequest <Verification> request) { Logger.Debug("Verification", request); return(Ok(await TryCatchResponseBase(request, ValidateType.Pending, async(RentoResponse response) => { if (!ValidateRequirdField(request.Data.Code)) { response.ErrorCode = ErrorCode.RequirdField; return; } ; var cacheReponse = RentoCache.Get <ForgetPasswordCacheObject>(VERIFICATION_KEY + request.Token); if (cacheReponse != null) { if (request.Data.Code.Equals(cacheReponse.Code)) { await AccountManager.Verify(cacheReponse.UserId); UserSession.Type = (int)UserType.Customer_Active; GenerateToken(UserSession); } else { response.ErrorCode = ErrorCode.InvalidCode; } } else { response.ErrorCode = ErrorCode.UserDoesNotExist; } }))); }
public async Task <IHttpActionResult> UpdateCustomerInfo(RentoRequest <CustomerOptinal> request) { return(Ok(await TryCatchResponseBase(request, ValidateType.Active, async(RentoResponse response) => { var identefier = request.Data.Identifier.Content; request.Data.Identifier.Content = "Base64 string"; var licence = request.Data.Licence.Content; request.Data.Licence.Content = "Base64 string"; Logger.Debug("UpdateCustomerInfo", request.Data); request.Data.Licence.Content = licence; request.Data.Identifier.Content = identefier; if (!string.IsNullOrEmpty(request.Data.BirthDate)) { request.Data.DOP = DateTime.ParseExact(request.Data.BirthDate, "dd/MM/yyyy", null); } if (!ValidateRequirdField(request.Data.Identifier, request.Data.Licence) || !ValidateRequirdField(request.Data.IdentifierId) || !ValidateRequirdField(request.Data.DOP) || !ValidateRequirdField(request.Data.Id) ) { response.ErrorCode = ErrorCode.RequirdField; return; } request.Data.Flag = (int)CustomerFlag.CompleteFromUpdate; await Database.AccountManager.UpdateCustomer(request.Data); }))); }
public async Task <IHttpActionResult> UpdateUserInfo(RentoRequest <User> request) { return(Ok(await TryCatchResponseBase(request, ValidateType.Pending, async(RentoResponse response) => { var licence = request.Data.Licence; var logo = request.Data.Logo; var refarmeCard = request.Data.RefarmeCard; if (request.Data.Licence != null) { if (!Rento.Helper.FileExtension.ScanImage(request.Data.Licence.Content)) { response.ErrorCode = ErrorCode.InvalidImageFormat; return; } request.Data.Licence = new RentoImage(); } if (request.Data.Logo != null) { if (!Rento.Helper.FileExtension.ScanImage(request.Data.Logo.Content)) { response.ErrorCode = ErrorCode.InvalidImageFormat; return; } request.Data.Logo = new RentoImage(); } if (request.Data.RefarmeCard != null) { if (!Rento.Helper.FileExtension.ScanImage(request.Data.RefarmeCard.Content)) { response.ErrorCode = ErrorCode.InvalidImageFormat; return; } request.Data.RefarmeCard = new RentoImage(); } Logger.Debug("User - UpdateUserInfo", request); request.Data.Licence = licence; request.Data.Logo = logo; request.Data.RefarmeCard = refarmeCard; if (!ValidateRequirdField(request.Data.CityId, request.Data.CountryId) || ((UserType)UserSession.Type == UserType.Pending && (request.Data.Licence == null || request.Data.RefarmeCard == null)) || !ValidateRequirdField(request.Data.Mobile, request.Data.Name) || !ValidateRequirdField(request.Data.Latitude, request.Data.Latitude) ) { response.ErrorCode = ErrorCode.RequirdField; return; } request.Data.Mobile = SMSMessage.CheckMobileNumber(request.Data.Mobile); request.Data.Id = UserSession.Id; await Database.AccountManager.Update(request.Data); if ((UserType)UserSession.Type == UserType.Pending) { UserSession.Type = (int)UserType.Active; } RentoCache.Set(request.Data.Id.ToString(), (byte)UserSession.Type); }))); }
public async Task <IHttpActionResult> ChangeStatus(RentoRequest <int> request) { Logger.Debug("Car - ChangeStatus", request); return(Ok(await TryCatchResponseBase(request, ValidateType.Active, async(RentoResponse response) => { await CarManager.ChangeStatus(UserSession.Id, request.Data); }))); }
public async Task <IHttpActionResult> List(RentoRequest request) { Logger.Debug("Message - List", request); return(Ok(await TryCatchResponse(request, ValidateType.Block, async(RentoResponse <List <Message> > response) => { response.Data = await Database.MessageManager.List(UserSession.Id); }))); }
public async Task <IHttpActionResult> Get(RentoRequest <int> request) { Logger.Debug("Car - Get", request); return(Ok(await TryCatchResponse(request, ValidateType.Active, async(RentoResponse <Car> response) => { response.Data = await CarManager.Select(UserSession.Id, request.Data); }))); }
public async Task <IHttpActionResult> ListProvider(RentoRequest request) { Logger.Debug("User - ListProvider", request); return(Ok(await TryCatchResponse(request, ValidateType.Operation, async(RentoResponse <List <SelectModel> > response) => { response.Data = await Database.UserManager.ListProvider(UserSession.Id); }))); }
public async Task <IHttpActionResult> List(RentoRequest request) { Logger.Debug("User - List", request); return(Ok(await TryCatchResponse(request, ValidateType.Active, async(RentoResponse <List <BaseNameEntity <UserType> > > response) => { response.Data = await Database.AccountManager.List((UserType)UserSession.Type); }))); }
public async Task <IHttpActionResult> List(RentoRequest request) { Logger.Debug("Offer - List", request); return(Ok(await TryCatchResponse(request, ValidateType.None, async(RentoResponse <List <Offer> > response) => { response.Data = await Database.OfferManager.List(0); }))); }
public IHttpActionResult RefreshToken(RentoRequest <TokenRefresh> request) { var response = new RentoResponse(request); return(Ok(TryCatch(request, response, ValidateType.None, async() => { await AccountManager.RefreshToken(request.Data); }))); }
public IHttpActionResult List(RentoRequest request) { var response = new RentoResponse <List <CarActionBaseInfo> >(request); return(Ok(TryCatch(request, response, ValidateType.Active, async() => { response.Data = await CarManager.ListRequest(UserSession.Id, true); }))); }
public async Task <IHttpActionResult> ListMobileCustomer(RentoRequest <MobileCustomerRequest> request) { Logger.Debug("User - ListMobileCustomer", request); return(Ok(await TryCatchResponse(request, ValidateType.Operation, async(RentoResponse <List <MobileCustomerResponse> > response) => { var tempResponse = await Database.AccountManager.ListMobileCustomer(request.Data, request.PageNumber, Constant.PAGE_SIZE); response.Data = tempResponse.Data; response.RowsCount = tempResponse.RowsCount; }))); }
public IHttpActionResult List(RentoRequest request) { Logger.Debug("User - List", request); var response = new RentoResponse <List <BaseNameEntity <UserType> > >(request); return(Ok(TryCatch(request, response, ValidateType.Active, async() => { response.Data = await Database.AccountManager.List((UserType)UserSession.Type); }))); }
public IHttpActionResult Get(RentoRequest <int> request) { Logger.Debug("Car - Get", request); var response = new RentoResponse <Car>(request); return(Ok(TryCatch(request, response, ValidateType.Active, async() => { response.Data = await CarManager.Select(UserSession.Id, request.Data); }))); }
public IHttpActionResult ChangeStatus(RentoRequest <int> request) { Logger.Debug("Car - ChangeStatus", request); var response = new RentoResponse(request); return(Ok(TryCatch(request, response, ValidateType.Active, async() => { await CarManager.ChangeStatus(UserSession.Id, request.Data); }))); }
public IHttpActionResult ListProvider(RentoRequest request) { Logger.Debug("User - ListProvider", request); var response = new RentoResponse <List <SelectModel> >(request); return(Ok(TryCatch(request, response, ValidateType.Operation, async() => { response.Data = await Database.UserManager.ListProvider(UserSession.Id); }))); }
public IHttpActionResult List(RentoRequest request) { Logger.Debug("Offer - List", request); var response = new RentoResponse <List <Offer> >(request); return(Ok(TryCatch(request, response, ValidateType.None, async() => { response.Data = await Database.OfferManager.List(0); }))); }
public IHttpActionResult List(RentoRequest request) { Logger.Debug("Organization - List", request); var response = new RentoResponse <List <Organization> >(request); return(Ok(TryCatch(request, response, ValidateType.Block, async() => { response.Data = await OrganizationManager.List(UserSession.Id); }))); }
public async Task <IHttpActionResult> Delete(RentoRequest <int> request) { return(Ok(await TryCatchResponseBase(request, ValidateType.Operation, async(RentoResponse response) => { var code = await CarManager.Delete(UserSession.Id, request.Data); if (code == 0) { response.ErrorCode = ErrorCode.CarLinkWithOrder; } }))); }
public async Task <IHttpActionResult> SendSMS(RentoRequest <SMSMessageEntity> request) { return(Ok(await TryCatchSyncBase(request, ValidateType.Operation, (RentoResponse response) => { if (!ValidateRequirdField(request.Data.Body, request.Data.Mobile)) { response.ErrorCode = ErrorCode.RequirdField; return; } ; SMSMessage.Send(SMSMessage.CheckMobileNumber(request.Data.Mobile), request.Data.Body); }))); }