コード例 #1
0
        public ActionResult Create()
        {
            CMSHelper help = new CMSHelper();

            @ViewBag.Title         = "";
            @ViewBag.MessageStatus = TempData["MessageStatus"];
            @ViewBag.Message       = TempData["Message"];
            RegisterSMSModel model  = new RegisterSMSModel();
            List <Group>     groups = new List <Group>();
            List <Site>      sites  = new List <Site>();
            int    CurrentUserId    = WebMatrix.WebData.WebSecurity.CurrentUserId;
            string userName         = User.Identity.Name;

            if (userName == "administrator")
            {
                groups = groupService.groupResponsitory.GetAll().ToList();
                sites  = sitesService.sitesResponsitory.GetAll().ToList();
            }
            else
            {
                int   groupId = userProfileService.userProfileResponsitory.Single(CurrentUserId).Group_Id.Value;
                Group group   = groupService.groupResponsitory.Single(groupId);
                sites = sitesService.GetBygroupId(groupId).ToList();
                groups.Add(group);
            }

            ViewBag.listGroup       = groups;
            ViewBag.listObservation = observationService.observationResponsitory.GetAll();
            ViewBag.listSite        = sites;
            ViewBag.listSmsServer   = sMSServerService.smsServerResponsitory.GetAll();
            return(View(model));
        }
コード例 #2
0
        public ActionResult Create(RegisterSMSModel model, string[] CodeObservation)
        {
            string listCode = "";
            int    i        = 1;

            foreach (var item in CodeObservation)
            {
                if (i == 1)
                {
                    listCode = listCode + item.Trim();
                }
                else
                {
                    listCode = listCode + "," + item.Trim();
                }
                i++;
            }
            if (ModelState.IsValid)
            {
                RegisterSMS pts           = new RegisterSMS();
                bool        checkSave     = false;
                int         CurrentUserId = WebMatrix.WebData.WebSecurity.CurrentUserId;
                pts = model.ToEntity(pts);
                pts.CodeObservation       = listCode;
                pts.DateCreate            = DateTime.Now;
                checkSave                 = registerSMSService.registerResponsitory.Insert(pts);
                TempData["MessageStatus"] = checkSave;
                TempData["Message"]       = $"Thêm mới đăng ký nhận tin {(checkSave ? "" : "không")} thành công";
                return(RedirectToAction("index"));
            }
            return(View(model));
        }
コード例 #3
0
        public ActionResult Update(RegisterSMSModel model, string[] CodeObservation)
        {
            if (ModelState.IsValid)
            {
                int    i        = 1;
                string listCode = "";
                foreach (var item in CodeObservation)
                {
                    if (i == 1)
                    {
                        listCode = listCode + item.Trim();
                    }
                    else
                    {
                        listCode = listCode + "," + item.Trim();
                    }
                    i++;
                }
                RegisterSMS pts = registerSMSService.registerResponsitory.Single(model.Id);
                if (pts == null)
                {
                    return(RedirectToAction("index"));
                }
                bool checkSave = false;
                pts = model.ToEntity(pts);
                pts.CodeObservation       = listCode;
                checkSave                 = registerSMSService.registerResponsitory.Update(pts);
                TempData["MessageStatus"] = checkSave;
                TempData["Message"]       = $"Cập nhật đăng ký nhận tin {(checkSave ? "" : "không")} thành công";

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
コード例 #4
0
 public static RegisterSMS ToEntity(this RegisterSMSModel model, RegisterSMS source = null)
 {
     if (source == null)
     {
         source = new RegisterSMS
         {
             Id              = source.Id,
             DanhSachSDT     = source.DanhSachSDT,
             CodeObservation = source.CodeObservation,
             DeviceId        = source.DeviceId,
             DateCreate      = source.DateCreate,
             GroupId         = source.GroupId,
             SMSServerId     = source.SMSServerId,
         };
     }
     source.Id              = model.Id;
     source.DanhSachSDT     = model.DanhSachSDT;
     source.CodeObservation = model.CodeObservation;
     source.DeviceId        = model.DeviceId;
     source.DateCreate      = model.DateCreate;
     source.GroupId         = model.GroupId;
     source.SMSServerId     = model.SMSServerId;
     return(source);
 }