public IActionResult Add([FromBody] AddRequestModel requestModel, [FromHeader] string displayLanguage) { var responseModel = new ApiResponseModel <Data.Entity.Profile>(); responseModel.DisplayLanguage = displayLanguage; try { var record = new Data.Entity.Profile(); record.Code = requestModel.Code; record.Name = requestModel.Name; record.IsDeleted = false; var dbResult = _profileService.Add(record); if (dbResult > 0) { responseModel.Data = record; // oluşturulan entity bilgisinde id kolonu atanmış olur ve entity geri gönderiliyor responseModel.ResultStatusCode = ResultStatusCodeStatic.Success; responseModel.ResultStatusMessage = "Success"; return(Ok(responseModel)); } else { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = "Could Not Be Saved"; responseModel.Data = null; return(StatusCode(StatusCodes.Status500InternalServerError, responseModel)); } } catch (Exception ex) { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = ex.Message; responseModel.Data = null; return(StatusCode(StatusCodes.Status500InternalServerError, responseModel)); } }
public ActionResult <AppProfileResource> Create(AppProfileResource resource) { var model = resource.ToModel(); model = _profileService.Add(model); return(Created(model.Id)); }
public ApiResponseModel <Profile> Add([FromBody] AddRequestModel requestModel) { var responseModel = new ApiResponseModel <Profile>(); try { var record = new Profile(); record.Name = requestModel.Name; record.Code = requestModel.Code; record.IsDeleted = false; var dbResult = _profileService.Add(record); if (dbResult > 0) { responseModel.Data = record; // oluşturulan entity bilgisinde id kolonu atanmış olur ve entity geri gönderiliyor responseModel.ResultStatusCode = ResultStatusCodeStatic.Success; responseModel.ResultStatusMessage = "Success"; } else { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = "Could Not Be Saved"; } } catch (Exception ex) { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = ex.Message; } return(responseModel); }
public ActionResult Create(ProfileModel model) { try { if (ModelState.IsValid) { try { model.DataCadastro = DateTime.Now; _profileService.Add(Mapper.Map <ProfileModel, Profile>(model), CurrentUser.UserId); ShowMessageDialog(MensagensResource.SucessoCadastrar, Message.MessageKind.Success); } catch (Exception e) { ShowMessageDialog(MensagensResource.ErroCadastrar, e); } } else { return(View(model)); } } catch (Exception e) { ShowMessageDialog(MensagensResource.ErroCadastrar, e); } return(RedirectToAction("Index")); }
private int Create(ProfileResource resource) { var model = resource.InjectTo <Profile>(); model = _profileService.Add(model); return(model.Id); }
private int Create(QualityProfileResource resource) { var model = resource.ToModel(); model = _profileService.Add(model); return(model.Id); }
public IActionResult Create([Bind("last_name,first_name,phone,email,preferred_name,address,city,state,country,dob,user_id,profile_type,education_level,status,marital_status")] mp_profile mp_profile) { if (ModelState.IsValid) { _profileService.Add(mp_profile); return(RedirectToAction(nameof(Index))); } return(View(mp_profile)); }
public IActionResult Add([FromBody] AddRequestModel requestModel, [FromHeader] string displayLanguage) { var responseModel = new Return <Data.Entity.Profile>(); responseModel.DisplayLanguage = displayLanguage; TokenModel tokenModel = TokenHelper.DecodeTokenFromRequestHeader(Request); var employeeId = tokenModel.Id; try { var record = new Data.Entity.Profile(); record.Code = requestModel.Code; record.Name = requestModel.Name; record.IsDeleted = false; record.CreatedBy = employeeId; record.CreatedDateTime = DateTime.Now; var dbResult = _profileService.Add(record); if (dbResult > 0) { responseModel.Data = record; // oluşturulan entity bilgisinde id kolonu atanmış olur ve entity geri gönderiliyor responseModel.Status = ResultStatusCodeStatic.Success; responseModel.Message = "Success"; responseModel.Success = true; return(Ok(responseModel)); } else { responseModel.Status = ResultStatusCodeStatic.InternalServerError; responseModel.Message = "Could Not Be Saved"; responseModel.Success = false; ReturnError error = new ReturnError(); error.Key = "500"; error.Message = "Could Not Be Saved"; error.Code = 500; responseModel.Errors = new List <ReturnError>(); responseModel.Errors.Add(error); responseModel.Data = null; //hata oluştugundan dolayı Data null olarak dönülür. return(StatusCode(StatusCodes.Status500InternalServerError, responseModel)); } } catch (Exception ex) { responseModel.Status = ResultStatusCodeStatic.InternalServerError; responseModel.Message = "An error occurred"; responseModel.Success = false; ReturnError error = new ReturnError(); error.Key = "500"; error.Message = ex.Message; error.Code = 500; responseModel.Errors = new List <ReturnError>(); responseModel.Errors.Add(error); responseModel.Data = null; //hata oluştugundan dolayı Data null olarak dönülür. return(StatusCode(StatusCodes.Status500InternalServerError, responseModel)); } }
public IActionResult Post([FromBody] Profile profile) { try { return(Ok(_profileService.Add(profile).ToApiModel())); } catch (Exception ex) { ModelState.AddModelError("AddProfile", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult ProfileForm(ProfileDTO profile) { if (ModelState.IsValid) { try { profile.Id = _profileService.Add(profile); return(View("ProfileSuccess", profile.FullName)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(View("ProfileError", "Ошибка при добавлении профиля.")); } } return(View(profile)); }
public ActionResult Add(AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { Profile profile = new Profile(); profile.Code = model.Code; profile.Name = model.Name; profile.IsDeleted = false; _profileService.Add(profile); return(RedirectToAction("Add", "Profile", new { IsSuccess = "True" })); } catch { return(RedirectToAction("Add", "Profile", new { IsSuccess = "False" })); } }
public ActionResult Add(Models.Profile.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Business.Models.Profile.AddRequestModel profile = new Business.Models.Profile.AddRequestModel(); profile.Code = model.Code; profile.Name = model.Name; var apiResponseModel = _profileService.Add(profile).Result; if (apiResponseModel.Status == ResultStatusCodeStatic.Success) { return(RedirectToAction(nameof(ProfileController.List))); } else { ViewBag.ErrorMessage = apiResponseModel.Message != null ? apiResponseModel.Message : "Kaydedilemedi.";//todo: kulturel olacak NotSaved return(View(model)); } }
public ActionResult Add(Models.Profile.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Data.Entity.Profile profile = new Data.Entity.Profile(); profile.Code = model.Code; profile.Name = model.Name; var result = _profileService.Add(profile); if (result > 0) { return(RedirectToAction(nameof(ProfileController.List))); } else { ViewBag.ErrorMessage = "Not Saved."; return(View(model)); } }
public ActionResult Add(Models.Profile.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Business.Models.Profile.Profile profile = new Business.Models.Profile.Profile(); profile.Code = model.Code; profile.Name = model.Name; var apiResponseModel = _profileService.Add(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, profile); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { return(RedirectToAction(nameof(ProfileController.List))); } else { ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage != null ? apiResponseModel.ResultStatusMessage : "Not Saved."; ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList; return(View(model)); } }
public ActionResult Add(Models.Profile.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } HealthyDuty.Data.Entity.Profile profile = new HealthyDuty.Data.Entity.Profile(); profile.Code = model.Code; profile.Name = model.Name; profile.CreatedBy = SessionHelper.CurrentUser.Id; profile.CreatedDateTime = DateTime.Now; profile.IsDeleted = false; try { _profileService.Add(profile); return(RedirectToAction(nameof(ProfileController.List))); } catch { ViewBag.ErrorMessage = "Not Saved."; return(View(model)); } }
private int Create(ProfileResource resource) { var model = resource.ToModel(); return(_profileService.Add(model).Id); }
public void Post(mp_profile profile) { _profileService.Add(profile); }
public async Task <Return <Profile> > Add(AddRequestModel addRequestModel) { Return <Profile> result = new Return <Profile>(); return(await _client.Add(addRequestModel)); }
public async Task <ActionResult> RegisterClient(IFormCollection collection, mp_profile profile, mp_enrollment enrollment, mp_couple_screening couple_screening, mp_child_screening child_Screening) { if (!string.IsNullOrWhiteSpace(collection["religion_other"])) { enrollment.religion = Options.AddLookup(new mp_lookup { category = "religion", value = collection["religion_other"] }).id; } if (!string.IsNullOrWhiteSpace(collection["preferred_language_other"])) { profile.language = Options.AddLookup(new mp_lookup { category = "preferred_language", value = collection["preferred_language_other"] }).id; } if (!string.IsNullOrWhiteSpace(collection["tribe_other"])) { profile.tribe = Options.AddLookup(new mp_lookup { category = "tribe", value = collection["tribe_other"] }).id; } if (!string.IsNullOrWhiteSpace(collection["child_preferred_language_other"])) { child_Screening.child_preferred_language = Options.AddLookup(new mp_lookup { category = "preferred_language", value = collection["child_preferred_language_other"] }).id; } var appointment_type_id = Convert.ToInt32(collection["appointment_type"]); var appointment_activity_id = Convert.ToInt32(collection["appointment_category_id"]); var appointment_activity_sub_id = Convert.ToInt32(collection["appointment_category_sub_id"]); //auth data var username = collection["username"]; //var roles = collection["roles"].ToString().Split(","); var password = collection["password"]; //end of auth data //step-1 int marital_status = Convert.ToInt32(collection["marital_status"]); int religious = Convert.ToInt32(collection["religious"]); int religion = Convert.ToInt32(collection["religion"]); int help_reason = Convert.ToInt32(collection["help_reason"]); int earlier_counseling = Convert.ToInt32(collection["earlier_counseling"]); int physical_health = Convert.ToInt32(collection["physical_health"]); int eating_habit = Convert.ToInt32(collection["eating_habit"]); int sleeping = Convert.ToInt32(collection["sleeping"]); int depression = Convert.ToInt32(collection["depression"]); int reduced_interest = Convert.ToInt32(collection["reduced_interest"]); int recent_depression = Convert.ToInt32(collection["recent_depression"]); int sleeping_trouble = Convert.ToInt32(collection["sleeping_trouble"]); int tiredness = Convert.ToInt32(collection["tiredness"]); int appetite = Convert.ToInt32(collection["appetite"]); int feeling_bad = Convert.ToInt32(collection["feeling_bad"]); int concentration_issue = Convert.ToInt32(collection["concentration_issue"]); int fidgety = Convert.ToInt32(collection["fidgety"]); int suicidal = Convert.ToInt32(collection["suicidal"]); int today_feeling = Convert.ToInt32(collection["today_feeling"]); int employed = Convert.ToInt32(collection["employed"]); int alcohol = Convert.ToInt32(collection["alcohol"]); int anxiety = Convert.ToInt32(collection["anxiety"]); bool?clinicalTherapyFaith = Convert.ToBoolean(collection["clinicalTherapyFaith"]); //end step-1 //step-2 var last_name = collection["last_name"]; var first_name = collection["first_name"]; var phone = collection["phone"]; var email = collection["email"]; var preferred_name = collection["preferred_name"]; var address = collection["address"]; var city = collection["city"]; var area = collection["area"]; var school_name = collection["school_name"]; int state = Convert.ToInt32(collection["state"]); int country = Convert.ToInt32(collection["country"]); var dob = DateTime.Parse(collection["dob"]); int education_level = Convert.ToInt32(collection["education_level"]); //end step-2 //emergency contact var emergency_last_name = collection["emergency_last_name"]; var emergency_first_name = collection["emergency_first_name"]; var emergency_phone = collection["emergency_phone"]; var emergency_email = collection["emergency_email"]; //var jsonMsg = FormHelper.ColletionToJSON(collection); var UserManager = _userManager; var user = new ApplicationUser { UserName = username, Email = username, PhoneNumber = profile.phone, UserType = 1, RegistrationDate = DateTime.Now }; var result = await UserManager.CreateAsync(user, password); if (result.Succeeded) { await UserManager.AddToRoleAsync(user, "client"); try { Guid profile_id = _profileService.Add(new mp_profile { last_name = last_name, first_name = first_name, phone = phone, email = email, preferred_name = preferred_name, address = address, area = area, city = city, state = state, country = country, dob = dob, user_id = user.Id, profile_type = 1, education_level = education_level, school_name = school_name, status = 0, marital_status = marital_status }); _emergencyContactService.Add(new mp_emergency_contact { first_name = emergency_first_name, last_name = emergency_last_name, email = emergency_email, phone = emergency_phone, profile_id = profile_id, created_by = username }); _enrollmentService.Add(new mp_enrollment { profile_id = profile_id, religious = religious, religion = religion, help_reason = help_reason, earlier_counseling = earlier_counseling, physical_health = physical_health, eating_habit = eating_habit, sleeping = sleeping, depression = depression, reduced_interest = reduced_interest, recent_depression = recent_depression, sleeping_trouble = sleeping_trouble, tiredness = tiredness, appetite = appetite, feeling_bad = feeling_bad, concentration_issue = concentration_issue, fidgety = fidgety, suicidal = suicidal, today_feeling = today_feeling, employed = employed, alcohol = alcohol, anxiety = anxiety, clinicalTherapyFaith = clinicalTherapyFaith, created_by = username }); if (appointment_type_id == 1 && appointment_activity_sub_id == 1) { //individual counselling enrollment.created_by = user.Id; enrollment.profile_id = profile_id; _enrollmentService.Add(enrollment); } else if (appointment_type_id == 1 && appointment_activity_sub_id == 2) { //couples counselling enrollment.created_by = user.Id; enrollment.profile_id = profile_id; _enrollmentService.Add(enrollment); couple_screening.profile_id = profile_id; _coupleScreeningService.Add(couple_screening); } else if (appointment_type_id == 1 && appointment_activity_sub_id == 3) { //child counselling enrollment.created_by = user.Id; enrollment.profile_id = profile_id; _enrollmentService.Add(enrollment); child_Screening.profile_id = profile_id; _evaluationService.AddChildScreening(child_Screening); } else if (appointment_type_id == 1 && appointment_activity_sub_id == 4) { //familiy counselling enrollment.created_by = user.Id; enrollment.profile_id = profile_id; _enrollmentService.Add(enrollment); } //var profile_match = new mp_profile_match //{ // appointment_type_id = appointment_type_id, // appointment_activity_id = appointment_activity_id, // appointment_activity_sub_id = appointment_activity_sub_id, // clinician_id = Guid.Parse(collection["clinician_id"]), // profile_id = profile_id //}; //_profileMatchService.Add(profile_match); await _emailSender.SendEmailAsync(user.Email, "Registration successful - MySpace MyTime", $"Thanks you " + last_name + " " + first_name + " for creating a profile with us."); //Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a> //return LocalRedirect("/Identity/Account/Login"); return(Ok(200)); } catch (Exception ex) { //error message handling var errMsg = "There was an error creating your account. " + ex.Message; return(Ok(errMsg)); } // var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); //var url = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}"; //var callbackUrl = url; // await _signInManager.SignInAsync(user, isPersistent: false); //await _emailSender.SendEmailAsync(collection["username"].ToString(), "Welcome to MySpace MyTime", //$"Your account has successfully being created."); //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); //code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); //var callbackUrl = Url.Page( // "/Account/ConfirmEmail", // pageHandler: null, // values: new { area = "Identity", userId = user.Id, code = code }, // protocol: Request.Scheme); //await _emailSender.SendEmailAsync(user.Email, "Your account has successfully being created. <br>", // $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); } // If we got this far, something failed, redisplay form var errors = "There was an error creating your account. Please ensure that the you use a strong password"; if (result.Errors != null && result.Errors.Count() > 0) { errors = string.Join(',', result.Errors.Select(x => x.Description).ToList()); } return(Ok(errors)); //return Redirect(Request.Headers["Referer"].ToString()); }
public async Task <ActionResult <UserProfileResponse?> > Add(UserProfile?userProfile) { var userResponse = await _profileService.Add(userProfile); return(StatusCode(userResponse.ApiFeedback.HttpCode, userResponse)); }