Exemple #1
0
        public ActionResult Edit(TypeViewModel typeVM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient())
                    {
                        TypeDto typeDto = new TypeDto
                        {
                            Id          = typeVM.Id,
                            Name        = typeVM.Name,
                            Description = typeVM.Description
                        };

                        service.PostType(typeDto);
                    }

                    return(RedirectToAction("Index"));
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }
Exemple #2
0
 public static SelectList LoadTypesData()
 {
     using (TypeServiceReference.TypeClient typeService = new TypeServiceReference.TypeClient())
     {
         SelectList selectListItems = new SelectList(typeService.GetTypes(), "Id", "Name");
         return(selectListItems);
     }
 }
Exemple #3
0
        public ActionResult Delete(int id)
        {
            TypeViewModel typeVM = new TypeViewModel();

            using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient())
            {
                service.DeleteType(id);
            }
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public ActionResult Edit(int id)
        {
            TypeViewModel typeVM = new TypeViewModel();

            using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient())
            {
                var typeDto = service.GetTypeById(id);
                typeVM = new TypeViewModel(typeDto);
            }

            return(View(typeVM));
        }
Exemple #5
0
        // GET: Type
        public ActionResult Index()
        {
            List <TypeViewModel> typeVM = new List <TypeViewModel>();

            using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient())
            {
                foreach (var item in service.GetTypes())
                {
                    typeVM.Add(new TypeViewModel(item));
                }
            }
            return(View(typeVM));
        }