public IActionResult Create(OwnerEditViewModel ownerVM) { try { //ownerVM.Owner.OwnerId = ownerVM.OwnerId; if (ModelState.IsValid) { _ownerService.Create(ownerVM); _ownerService.Save(); //finally commit TempData.Add("ResultMessage", "Owner created Successfully!"); return(RedirectToAction("Index")); } return(View(ownerVM)); } catch { } //ownerVM.ownersList = GetownerList(); return(View(ownerVM)); }
public IActionResult Create(RoomOwner owner) { if (ModelState.IsValid) { owner.OwnerId = _ownerService.GenerateIdRandom(owner.OwnerId); if (owner.OwnerId != null) { var result = _ownerService.IfEmailExist(owner.Email); if (result == false) { owner.Password = _ownerService.EncryptPassword(Encoding.UTF8, owner.Password); owner.TypeOfUser = 1; _ownerService.Create(owner); HttpContext.Session.SetString("Name", owner.Name + " " + owner.Lastname); HttpContext.Session.SetString("Id", owner.OwnerId); return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("Email", _localizer["Now this email is used, please enter a new!"].ToString()); return(View(owner)); } } } return(View(owner)); }
public ActionResult <Owner> Post([FromBody] Owner owner) { if (string.IsNullOrEmpty(owner.FirstName)) { return(BadRequest("First Name missing!")); } if (string.IsNullOrEmpty(owner.SecondName)) { return(BadRequest("Second Name missing!")); } if (string.IsNullOrEmpty(owner.Address)) { return(BadRequest("Address missing!")); } if (owner.Age <= 0 || owner.Age.Equals(null)) { return(BadRequest("Invalid age input!")); } if (owner.PhoneNumber <= 0 || owner.PhoneNumber.Equals(null)) { return(BadRequest("Invalid phone input!")); } _ownerService.Create(owner); return(StatusCode(500, "Owner created successfully!")); }
private void CreateOwner() { Console.WriteLine("-Add-"); Console.WriteLine("First name:"); string firstName = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Last name:"); string lastName = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Address:"); string address = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Phone number:"); string phoneNumber = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Email:"); string email = Console.ReadLine(); Console.WriteLine(); Owner owner = ownerService.New(firstName, lastName, address, phoneNumber, email); ownerService.Create(owner); ClearOwnerList(); ShowOwnerListData(ownerService.ReadAll()); }
public ActionResult <Owner> Post([FromBody] Owner value) { Owner owner = value; if (string.IsNullOrEmpty(owner.name)) { return(BadRequest("Name is required for creating Owner")); } return(_ownerService.Create(owner)); }
public ActionResult Post([FromBody] Owner owner) { try { return(Ok(_ownerService.Create(owner))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <Owner> Post([FromBody] Owner owner) { try { Owner ownerCreated = _ownerService.Create(owner); return(Created($"Owner with id {ownerCreated.Id} was created.", ownerCreated)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <Owner> Post([FromBody] Owner owner) { try { _ownerService.Create(owner); return(StatusCode(201, "Yes Sir! Owner is created.")); } catch (System.Exception) { return(StatusCode(500, "Error when creating owner")); } }
public ActionResult Post([FromBody] Owner owner) { try { return(Ok(_ownerService.Create(owner))); } catch (MissingMemberException e) { return(NotFound(e.Message)); } }
public async Task <object> CreateOwner(OwnerViewModel model) { Owner owner = new SimpleAutoMapper <Owner>().Map(model); try { if (await CheckPermissionToCreateUpdateOwner(owner)) { Response response = await _service.Create(owner); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public IActionResult Create(RoomOwner owner) { if (ModelState.IsValid) { owner.OwnerId = _ownerService.GenerateIdRandom(owner.OwnerId); if (owner.OwnerId != null) { var result = _ownerService.IfEmailExist(owner.Email); if (result == false) { owner.Password = _ownerService.EncryptPassword(Encoding.UTF8, owner.Password); _ownerService.Create(owner); } else { ModelState.AddModelError("Email", _localizer["Now this email is used, please enter a new!"].ToString()); return(View(owner)); } } return(RedirectToAction("HomePage", owner)); } return(View(owner)); }
public ActionResult <Owner> Post([FromBody] Owner owner) { return(_ownerService.Create(owner)); }