public async Task <IActionResult> RegisterUser(RegisterationModelForUsers registerationModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (await CheckIfUserExist(registerationModel.UserSecurity))
            {
                return(BadRequest());
            }

            registerationModel.UserInfo.UserAddress = registerationModel.Address;

            addressManager.Add(registerationModel.Address);
            dbContextUser.Add(registerationModel.UserInfo);

            string id = await AddUserToAspNetUsers(registerationModel.UserSecurity, registerationModel.UserInfo, "user");

            if (id != null)
            {
                string imagePath = UploadToCloudinary.UploadImageToCloudinary(registerationModel.UserInfo.ImagePath);

                if (imagePath != null)
                {
                    registerationModel.UserInfo.ImagePath     = imagePath;
                    registerationModel.UserInfo.AspNetUsersId = id;
                    dbContextUser.Complete();
                    return(Ok());
                }
            }
            return(BadRequest());
        }
Example #2
0
 public IHttpActionResult Create([FromBody] Address address)
 {
     try
     {
         return(Content(HttpStatusCode.OK, _addressManager.Add(address)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Example #3
0
 private void Save(object sender, EventArgs e)
 {
     if (areTextBoxesFilled())
     {
         var patientId = patientManager.Add(CreatePatient());
         addressManager.Add(CreateAddress(patientId));
         emergencyContactManager.Add(CreateEmergencyContact(patientId));
         consultationManager.Add(CreateConsultation(patientId));
         MessageBox.Show("Patient data saved successfully");
         this.Close();
     }
 }
        public ActionResult Create([Bind(Include = "Id,AddressType,AddressLine1,AddressLine2,PostOffice,PostCode,DivisionId,DistrictId,UpazilaId,EmployeeId")] Address address)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    address.AddressType = "Present Address";
                    _addressManager.Add(address);
                    return(RedirectToAction("Index"));
                }

                return(View());
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Addresses", "Create")));
            }
        }