Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Referred referred = await db.referreds.FindAsync(id);

            db.referreds.Remove(referred);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        // 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));
        }
Ejemplo n.º 5
0
        // 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));
        }
Ejemplo n.º 6
0
 public static Referred WithOrganisation(this Referred referred, Organisation organisation)
 {
     referred.Organisation = organisation;
     return(referred);
 }
Ejemplo n.º 7
0
 public static Referred WithIsActive(this Referred referred, Boolean isActive)
 {
     referred.IsActive = isActive;
     return(referred);
 }
Ejemplo n.º 8
0
 public static Referred WithDescription(this Referred referred, String description)
 {
     referred.Description = description;
     return(referred);
 }
Ejemplo n.º 9
0
 public static Referred WithSecurityLabel(this Referred referred, Guid securityLabel)
 {
     referred.SecurityLabel = securityLabel;
     return(referred);
 }
Ejemplo n.º 10
0
 public static Referred WithCode(this Referred referred, Guid code)
 {
     referred.Code = code;
     return(referred);
 }
Ejemplo n.º 11
0
        /// <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);
            }
        }
Ejemplo n.º 12
0
        /// <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);
            }
        }