public ActionResult Add(Guid officeGuid, string contactType = null) { if (officeGuid == Guid.Empty) { return(StatusCode(401)); } var contactTypes = _officeContactService.GetContactType(); OfficeContactViewModel officeContactViewModel = new OfficeContactViewModel(); officeContactViewModel.ContactTypeSelectListItems = contactTypes .Where(x => (x.Value == contactType || contactType == null)).ToDictionary(x => x.Key, x => x.Value); officeContactViewModel.OfficeGuid = officeGuid; return(PartialView(officeContactViewModel)); }
// GET: OfficeContact public ActionResult Index(string searchValue, Guid officeGuid) { if (officeGuid == Guid.Empty) { return(StatusCode(401)); } OfficeContactViewModel officeContactViewModel = new OfficeContactViewModel(); officeContactViewModel.SearchValue = searchValue; officeContactViewModel.OfficeGuid = officeGuid; var officedetails = _officeService.GetById(officeGuid); officeContactViewModel.OfficeName = officedetails.OfficeName; return(PartialView(officeContactViewModel)); }
public IActionResult Add([FromBody] OfficeContactViewModel officeContactViewModel) { try { var officeContactModel = Models.ObjectMapper <OfficeContactViewModel, OfficeContact> .Map(officeContactViewModel); Guid id = Guid.NewGuid(); officeContactModel.ContactGuid = id; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } officeContactModel.CreatedOn = DateTime.Now; officeContactModel.CreatedBy = id; officeContactModel.UpdatedOn = DateTime.Now; officeContactModel.UpdatedBy = id; officeContactModel.IsActive = true; officeContactModel.IsDeleted = false; var officeContact = _officeContactService.Add(officeContactModel); var jsonObjects = new { contactguid = officeContactModel.ContactGuid, searchvalue = officeContactModel.SearchValue, officeguid = officeContactModel.OfficeGuid, officeName = officeContactModel.OfficeName, officeLastName = officeContactModel.LastName, officePhoneNumber = officeContactModel.PhoneNumber, fullName = FormatHelper.FormatFullName(officeContactModel.FirstName, officeContactModel.MiddleName, officeContactModel.LastName) }; return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", officeContact = jsonObjects })); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Edit([FromBody] OfficeContactViewModel officeContactViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } officeContactViewModel.UpdatedOn = DateTime.Now; officeContactViewModel.UpdatedBy = UserHelper.CurrentUserGuid(); var officeContactModel = Models.ObjectMapper <OfficeContactViewModel, OfficeContact> .Map(officeContactViewModel); _officeContactService.Edit(officeContactModel); return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Updated !!", OfficeContact = new { SearchValue = " ", Officeguid = officeContactViewModel.OfficeGuid, OfficeName = officeContactViewModel.OfficeName } })); }