public async Task <UserDto> RegisterUserWithProgram(User model, int programCodeId, string photoPath = null) { try { var userInfo = await FindAsync(new { Email = model.Email, IsActive = true }); if (userInfo == null) { userInfo = new User(); } /* Saving the data for the user*/ userInfo.FirstName = model.FirstName; userInfo.LastName = model.LastName ?? null; userInfo.PhoneNumber = model.PhoneNumber; userInfo.Email = model.Email; userInfo.UserDeviceId = model.UserDeviceId ?? null; userInfo.UserDeviceType = model.UserDeviceType ?? null; userInfo.Location = model.Location ?? null; userInfo.SessionId = Guid.NewGuid().ToString(); userInfo.InvitationStatus = 3; userInfo.EmailConfirmed = true; userInfo.IsMobileRegistered = true; if (!string.IsNullOrEmpty(model.PasswordHash)) { PasswordHasher <User> _usr = new PasswordHasher <User>(); userInfo.PasswordHash = _usr.HashPassword(userInfo, model.PasswordHash); } var userId = 0; if (userInfo.Id > 0) { await UpdateAsync(userInfo, new { id = userInfo.Id }); userId = userInfo.Id; } else { userId = await AddAsync(userInfo); } /* Saving the data for the user image if the profile path is not null */ // if (!string.IsNullOrEmpty(photoPath)) // { await _photos.SaveUpdateImage(photoPath, userInfo?.Id > 0?userInfo.Id : userId, userInfo?.Id > 0?userInfo.Id : userId, (int)PhotoEntityType.UserProfile); // } return(await GetUserWithProgramCode(userId, programCodeId).ConfigureAwait(false)); } catch (Exception) { throw; } }
public async Task <string> AddEditBrandingDetails(ProgramBrandingViewModel model) { try { var bId = await AddEditBranding(model); if (bId > 0) { if (!string.IsNullOrEmpty(model.ImagePath)) { await _photos.SaveUpdateImage(model.ImagePath, bId, bId, (int)PhotoEntityType.BrandingLogo); } return(Cryptography.EncryptPlainToCipher(bId.ToString())); } return("0"); } catch (Exception) { throw; } }
public async Task <int> AddEditPromotion(MerchantRewardViewModel model) { try { var chkExist = await FindAsync(new { id = model.id }); if (chkExist == null) { chkExist = new Promotion(); } chkExist.amounts = model.amounts; chkExist.backgroundColor = model.backgroundColor; chkExist.bannerDescription = model.bannerDescription; chkExist.bannerTypeId = model.bannerTypeId; chkExist.businessTypeId = model.businessTypeId; if (model.createdBy != null) { chkExist.createdBy = model.createdBy; } if (model.createdDate != null) { chkExist.createdDate = model.createdDate; } chkExist.description = model.description; chkExist.endDate = model.endDate; chkExist.endTime = TimeSpan.Parse(model.endTime.ToString()); chkExist.firstGradiantColor = model.firstGradiantColor; chkExist.IsPublished = model.IsPublished; if (model.isActive != null) { chkExist.isActive = model.isActive; } if (model.isDeleted != null) { chkExist.isDeleted = model.isDeleted; } chkExist.MerchantId = model.MerchantId; if (model.modifiedBy != null) { chkExist.modifiedBy = model.modifiedBy; } if (model.modifiedDate != null) { chkExist.modifiedDate = model.modifiedDate; } chkExist.name = model.name; chkExist.noOfVisits = model.noOfVisits; if (model.IsPromotion) { var offerType = await _offerType.GetSingleDataByConditionAsync(new { offerType = "Promotions" }); if (offerType != null) { chkExist.offerTypeId = offerType.id; } if (model.IsDaily) { var offerSubType = await _offerSubType.GetSingleDataByConditionAsync(new { title = "Daily Promotion" }); if (offerSubType != null) { chkExist.offerSubTypeId = offerSubType.id; } } else { var offerSubType = await _offerSubType.GetSingleDataByConditionAsync(new { title = "Multi Day Promotion" }); if (offerSubType != null) { chkExist.offerSubTypeId = offerSubType.id; } } } else { chkExist.offerSubTypeId = model.offerSubTypeId; chkExist.offerTypeId = model.offerTypeId; } if (model.IsPromotion) { if (model.IsDaily) { chkExist.promotionDay = model.promotionDay; } } else { chkExist.promotionDay = model.promotionDay; } chkExist.startDate = model.startDate; chkExist.startTime = TimeSpan.Parse(model.startTime.ToString()); chkExist.id = model.id; var promotionId = await InsertOrUpdateAsync(chkExist, new { id = model.id }); if (promotionId > 0) { await _photos.SaveUpdateImage(model.ImagePath, promotionId, promotionId, (int)PhotoEntityType.OffersPromotions); } return(promotionId); } catch (Exception) { throw; } }