예제 #1
0
        // GET: SIMCards/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var filters = new List <GenericDataFormat.FilterItems>();

            filters.Add(new GenericDataFormat.FilterItems()
            {
                Property = "SIMCardId", Operation = GenericDataFormat.FilterOperations.Equal, Value = id
            });
            requestBody = new GenericDataFormat()
            {
                Filters = filters, Includes = new GenericDataFormat.IncludeItems()
                {
                    References = "SIMCardStatus"
                }
            };
            var items = new SIMCardModel <SIMCardViewModel>().Get(requestBody);

            if (items.Count < 1 || items.ElementAt(0) == null)
            {
                return(HttpNotFound());
            }

            var model = (SIMCardViewModel)items.ElementAt(0);

            model.BindCreate_Modify_User();

            return(View(model));
        }
예제 #2
0
        public ActionResult Import(FormCollection fc)
        {
            try
            {
                var file   = Request.Files["file"];
                var result = new SIMCardModel <SIMCard>().Import(file);
                if (result)
                {
                    TempData["AlertMessage"] = new AlertMessage()
                    {
                        MessageType = AlertMessageType.Success, MessageContent = "Import Data has been added"
                    };
                    return(RedirectToAction("Index"));
                }

                TempData["AlertMessage"] = new AlertMessage()
                {
                    MessageType = AlertMessageType.Success, MessageContent = "Import has failed"
                };
                return(RedirectToAction("Index"));
            }
            catch (AggregateException ex)
            {
                if (ex.InnerException is UnauthorizedAccessException)
                {
                    return(RedirectToAction("Unauthorized", "Login"));
                }

                throw ex;
            }
        }
예제 #3
0
        // GET: SIMCards/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SIMCard SimCard = new SIMCardModel <SIMCard>().Get((int)id);

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

            var SIMCardStatus = new SIMCardStatusModel <SIMCardStatus>().Get();

            var model = new EditSIMCardModel()
            {
                EditItem = SimCard,
                Status   = SIMCardStatus.Select(x => new SelectListItem()
                {
                    Selected = SimCard.SIMCardStatusId == x.SIMCardStatusId, Text = x.SIMCardStatusName_en, Value = x.SIMCardStatusId.ToString()
                })
            };

            return(View(model));
        }
예제 #4
0
        public ActionResult TestDesign()
        {
            requestBody = new GenericDataFormat()
            {
                Includes = new GenericDataFormat.IncludeItems()
                {
                    References = "SIMCardStatus"
                }
            };

            var model = new SIMCardModel <SIMCardViewModel>().Get(requestBody);

            return(View(model));
        }
예제 #5
0
        // GET: SIMCards
        public ActionResult Index()
        {
            if (TempData["AlertMessage"] != null)
            {
                ViewBag.AlertMessage = TempData["AlertMessage"];
            }
            requestBody = new GenericDataFormat()
            {
                Includes = new GenericDataFormat.IncludeItems()
                {
                    References = "SIMCardStatus"
                }
            };
            var model = new SIMCardModel <SIMCardViewModel>().Get(requestBody);

            return(View(model));
        }
예제 #6
0
 public ActionResult Export()
 {
     try
     {
         requestBody = new GenericDataFormat()
         {
             Includes = new GenericDataFormat.IncludeItems()
             {
                 Properties = "SIMCardId,SerialNumber,GSM,SIMCardStatus.SIMCardStatusName_en", References = "SIMCardStatus"
             }
         };
         var fileBytes = new SIMCardModel <SIMCard>().Export(requestBody);
         return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "SIMCards.xlsx"));
     }
     catch (AggregateException ex)
     {
         if (ex.InnerException is UnauthorizedAccessException)
         {
             return(RedirectToAction("Unauthorized", "Login"));
         }
         throw ex;
     }
 }