// GET: /ProductMaster/Create

        public ActionResult Create()
        {
            PersonContactType vm = new PersonContactType();

            vm.IsActive = true;
            return(View("Create", vm));
        }
예제 #2
0
 public static PersonContact Create(
     PersonContactType personContactType,
     string value)
 {
     return(new PersonContact(
                personContactType,
                value));
 }
예제 #3
0
 private PersonContact(
     PersonContactType personContactType,
     string value)
 {
     // ReSharper disable once VirtualMemberCallInConstructor
     PersonContactType = personContactType;
     Value             = value;
 }
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            PersonContactType pt = _PersonContactTypeService.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", pt));
        }
예제 #5
0
        public void UpdatePersonContact(int id, PersonContactType personContactType, string value)
        {
            var contact = PersonContacts
                          .FirstOrDefault(
                x => x.Id == id && !x.IsDeleted);

            if (contact == null)
            {
                throw new NotFoundException(
                          StringResource.Contact,
                          StringResource.Id,
                          id);
            }

            contact.Update(personContactType, value);
        }
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PersonContactType PersonContactType = _PersonContactTypeService.Find(id);

            if (PersonContactType == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
예제 #7
0
 public void Update(PersonContactType personContactType, string value)
 {
     PersonContactType = personContactType;
     Value             = value;
 }
        public ActionResult Post(PersonContactType vm)
        {
            PersonContactType pt = vm;

            if (ModelState.IsValid)
            {
                if (vm.PersonContactTypeId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _PersonContactTypeService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.PersonContactType).DocumentTypeId,
                        DocId        = pt.PersonContactTypeId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create").Success("Data saved successfully"));
                }

                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    PersonContactType temp = _PersonContactTypeService.Find(pt.PersonContactTypeId);

                    PersonContactType ExRec = Mapper.Map <PersonContactType>(temp);

                    temp.PersonContactTypeName = pt.PersonContactTypeName;
                    temp.IsActive     = pt.IsActive;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    temp.ObjectState  = Model.ObjectState.Modified;
                    _PersonContactTypeService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.PersonContactType).DocumentTypeId,
                        DocId           = temp.PersonContactTypeId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            return(View("Create", vm));
        }
예제 #9
0
 public PersonContactType Add(PersonContactType pt)
 {
     _unitOfWork.Repository <PersonContactType>().Insert(pt);
     return(pt);
 }
예제 #10
0
 public void Update(PersonContactType pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <PersonContactType>().Update(pt);
 }
예제 #11
0
 public void Delete(PersonContactType pt)
 {
     _unitOfWork.Repository <PersonContactType>().Delete(pt);
 }
예제 #12
0
 public PersonContactType Create(PersonContactType pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <PersonContactType>().Insert(pt);
     return(pt);
 }