/// <summary> /// Update a Referred /// </summary> /// <param name="currentUser"></param> /// <param name="user"></param> /// <param name="appID"></param> /// <param name="overrideID"></param> /// <param name="code"></param> /// <param name="lockID"></param> /// <param name="dataRepository"></param> /// <param name="uow"></param> public void DeleteReferred(string currentUser, string user, string appID, string overrideID, string code, string lockID, IRepository <Referred> dataRepository, IUnitOfWork uow) { try { #region Parameter validation // Validate parameters if (string.IsNullOrEmpty(currentUser)) { throw new ArgumentOutOfRangeException("currentUser"); } if (string.IsNullOrEmpty(user)) { throw new ArgumentOutOfRangeException("user"); } if (string.IsNullOrEmpty(appID)) { throw new ArgumentOutOfRangeException("appID"); } if (string.IsNullOrEmpty(code)) { throw new ArgumentOutOfRangeException("code"); } if (string.IsNullOrEmpty(lockID)) { throw new ArgumentOutOfRangeException("lockID"); } if (null == dataRepository) { throw new ArgumentOutOfRangeException("dataRepository"); } if (null == uow) { throw new ArgumentOutOfRangeException("uow"); } #endregion using (uow) { // Convert string to guid Guid codeGuid = Guid.Parse(code); // Find item based on ID Referred dataEntity = dataRepository.Single(x => x.Code == codeGuid); // Delete the item dataRepository.Delete(dataEntity); // Commit unit of work uow.Commit(); } } catch (Exception e) { //Prevent exception from propogating across the service interface ExceptionManager.ShieldException(e); } }
public async Task <ActionResult> DeleteConfirmed(int id) { Referred referred = await db.referreds.FindAsync(id); db.referreds.Remove(referred); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Family,NathionalCode,Phone,Age,Gender,RoomNumber,StayingTime")] Referred referred) { if (ModelState.IsValid) { db.Entry(referred).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Users, "Id", "Email", referred.Id); return(View(referred)); }
// GET: Admin/Referreds/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Referred referred = await db.referreds.FindAsync(id); if (referred == null) { return(HttpNotFound()); } return(View(referred)); }
// GET: Admin/Referreds/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Referred referred = await db.referreds.FindAsync(id); if (referred == null) { return(HttpNotFound()); } ViewBag.Id = new SelectList(db.Users, "Id", "Email", referred.Id); return(View(referred)); }
public static Referred WithOrganisation(this Referred referred, Organisation organisation) { referred.Organisation = organisation; return(referred); }
public static Referred WithIsActive(this Referred referred, Boolean isActive) { referred.IsActive = isActive; return(referred); }
public static Referred WithDescription(this Referred referred, String description) { referred.Description = description; return(referred); }
public static Referred WithSecurityLabel(this Referred referred, Guid securityLabel) { referred.SecurityLabel = securityLabel; return(referred); }
public static Referred WithCode(this Referred referred, Guid code) { referred.Code = code; return(referred); }
/// <summary> /// Create a Referred /// </summary> /// <param name="currentUser"></param> /// <param name="user"></param> /// <param name="appID"></param> /// <param name="overrideID"></param> /// <param name="dc"></param> /// <param name="dataRepository"></param> /// <param name="uow"></param> public ReferredVMDC CreateReferred(string currentUser, string user, string appID, string overrideID, ReferredDC dc, IRepository <Referred> dataRepository, IUnitOfWork uow) { try { #region Parameter validation // Validate parameters if (string.IsNullOrEmpty(currentUser)) { throw new ArgumentOutOfRangeException("currentUser"); } if (string.IsNullOrEmpty(user)) { throw new ArgumentOutOfRangeException("user"); } if (string.IsNullOrEmpty(appID)) { throw new ArgumentOutOfRangeException("appID"); } if (null == dc) { throw new ArgumentOutOfRangeException("dc"); } if (null == dataRepository) { throw new ArgumentOutOfRangeException("dataRepository"); } if (null == uow) { throw new ArgumentOutOfRangeException("uow"); } #endregion using (uow) { // Create a new ID for the Referred item dc.Code = Guid.NewGuid(); // Map data contract to model Referred destination = Mapper.Map <ReferredDC, Referred>(dc); // Add the new item dataRepository.Add(destination); // Commit unit of work uow.Commit(); } // Create aggregate data contract ReferredVMDC returnObject = new ReferredVMDC(); // Add new item to aggregate returnObject.ReferredItem = dc; return(returnObject); } catch (Exception e) { //Prevent exception from propogating across the service interface ExceptionManager.ShieldException(e); return(null); } }
/// <summary> /// Retrieve a Referred with associated lookups /// </summary> /// <param name="currentUser"></param> /// <param name="user"></param> /// <param name="appID"></param> /// <param name="overrideID"></param> /// <param name="code"></param> /// <param name="dataRepository"></param> /// <param name="uow"></param> /// <returns></returns> public ReferredVMDC GetReferred(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <Referred> dataRepository ) { try { #region Parameter validation // Validate parameters if (string.IsNullOrEmpty(currentUser)) { throw new ArgumentOutOfRangeException("currentUser"); } if (string.IsNullOrEmpty(user)) { throw new ArgumentOutOfRangeException("user"); } if (string.IsNullOrEmpty(appID)) { throw new ArgumentOutOfRangeException("appID"); } if (null == dataRepository) { throw new ArgumentOutOfRangeException("dataRepository"); } if (null == uow) { throw new ArgumentOutOfRangeException("uow"); } #endregion using (uow) { ReferredDC destination = null; // If code is null then just return supporting lists if (!string.IsNullOrEmpty(code)) { // Convert code to Guid Guid codeGuid = Guid.Parse(code); // Retrieve specific Referred Referred dataEntity = dataRepository.Single(x => x.Code == codeGuid); // Convert to data contract for passing through service interface destination = Mapper.Map <Referred, ReferredDC>(dataEntity); } // Create aggregate contract ReferredVMDC returnObject = new ReferredVMDC(); returnObject.ReferredItem = destination; return(returnObject); } } catch (Exception e) { //Prevent exception from propogating across the service interface ExceptionManager.ShieldException(e); return(null); } }