Exemplo n.º 1
0
        public ActionResult GetFile(HttpPostedFileBase file, Files files)
        {
            TDBContext db = new TDBContext();

            int MID = Convert.ToInt32(TempData["UID"]);
            int id  = Convert.ToInt32(TempData["UID"]);

            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string fil  = Path.GetFileName(file.FileName);
                    string path = Path.Combine(Server.MapPath("/App_Data/Uploads/"), fil);
                    file.SaveAs(path);
                    files.URL = "/App_Data/Uploads/" + file.FileName;
                }

                Files fc = new Files
                {
                    Title       = files.Title,
                    Description = files.Description,
                    URL         = files.URL,
                    MissionID   = MID
                };
                db.Files.Add(fc);
                db.SaveChanges();

                return(RedirectToAction("DList", new { id = MID }));
            }
            return(View(files));
        }
Exemplo n.º 2
0
        public ActionResult UpdateAction(ActionPoints model)
        {
            TDBContext db = new TDBContext();

            int MID = Convert.ToInt32(TempData["ID"]);

            ActionPoints ac = new ActionPoints
            {
                APID        = model.APID,
                Catagory    = model.Catagory,
                Priority    = model.Priority,
                ActionPoint = model.ActionPoint,
                DueDate     = model.DueDate,
                Responsible = model.Responsible,
                Remarks     = model.Remarks,
                MissionID   = MID
            };

            db.Entry(ac).State = EntityState.Modified;
            db.SaveChanges();

            string message = "Recored has been updated successfully.";
            bool   status  = true;

            return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult ACreate(ActionPoints actionPoints)
        {
            TDBContext db = new TDBContext();

            string message = "Saved Successfully";
            bool   status  = true;

            int MID = Convert.ToInt32(TempData["ID"]);


            ActionPoints ac = new ActionPoints
            {
                Catagory    = actionPoints.Catagory,
                Priority    = actionPoints.Priority,
                ActionPoint = actionPoints.ActionPoint,
                DueDate     = actionPoints.DueDate,
                Responsible = actionPoints.Responsible,
                Remarks     = actionPoints.Remarks,
                MissionID   = MID
            };

            db.ActionPoint.Add(ac);
            db.SaveChanges();
            return(Json(new { status = status, message = message, id = db.ActionPoint.Max(x => x.APID) }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult UpdateMission(ISM model)
        {
            TDBContext db = new TDBContext();

            db.Entry(model).State = EntityState.Modified;
            db.SaveChanges();
            string message = "Recored has been updated successfully.";
            bool   status  = true;

            return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult Create(ISM iSM)
        {
            TDBContext db = new TDBContext();

            string message = "Saved Successfully";
            bool   status  = true;

            db.ISM.Add(iSM);
            db.SaveChanges();
            return(Json(new { status = status, message = message, id = db.ISM.Max(x => x.MissionID) }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public JsonResult RegisterUser([FromBody] JObject data)
        {
            JToken userToken = data;

            using (var db = new TDBContext()){
                var exists = db.Users.Single(x => x.Username == (string)userToken.SelectToken("username"));

                if (exists == null)
                {
                    Guid   user_id    = Guid.NewGuid();
                    String username   = (string)userToken.SelectToken("username");
                    String first_name = (string)userToken.SelectToken("first_name");
                    String last_name  = (string)userToken.SelectToken("last_name");
                    String email      = (string)userToken.SelectToken("email");
                    String password   = (string)userToken.SelectToken("password");



                    var user = new User();
                    user.UserID     = user_id;
                    user.Username   = username;
                    user.email      = email;
                    user.first_name = first_name;
                    user.Password   = password;
                    user.last_name  = last_name;

                    try{
                        db.Users.Add(user);
                        db.SaveChanges();
                        MailService.SendMessage(first_name, last_name, email, "Thank you for Registering with us!");

                        return(Json(
                                   new {
                            success = true
                        }));
                    }
                    catch (Exception e) {
                        Console.WriteLine(e);
                        return(Json(
                                   new {
                            Message = "There was an issue, please try again later"
                        }));
                    }
                }
                else
                {
                    return(Json(
                               new {
                        Message = "User Exists"
                    }));
                }
            }
        }
Exemplo n.º 7
0
        public ActionResult Delete(int id)
        {
            TDBContext db = new TDBContext();

            var mission = db.ISM.Where(x => x.MissionID == id).FirstOrDefault();

            db.ISM.Remove(mission);
            db.SaveChanges();
            string message = "Record has been deleted successfully";
            bool   status  = true;

            return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public ActionResult FDelete(int ID)
        {
            using (var db = new TDBContext())
            {
                int MID = Convert.ToInt32(TempData["UID"]);
                int id  = Convert.ToInt32(TempData["UID"]);


                var data = db.Files.Find(ID);
                //var filename = Path.GetFileName(FilePath.FileName);
                var path = Request.MapPath(data.URL);

                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                    ViewBag.deleteSuccess = "true";
                }
                db.Files.Remove(data);
                db.SaveChanges();
                return(RedirectToAction("DList", new { id = MID }));
            }
        }
Exemplo n.º 9
0
        public ActionResult UpdateProgress(Progress model)
        {
            TDBContext db = new TDBContext();

            int MID = Convert.ToInt32(TempData["PID"]);

            Progress ac = new Progress
            {
                ProgID        = model.ProgID,
                Status        = model.Status,
                ReportingDate = model.ReportingDate,
                Percentage    = model.Percentage,
                APID          = MID
            };

            db.Entry(ac).State = EntityState.Modified;
            db.SaveChanges();

            string message = "Recored has been updated successfully.";
            bool   status  = true;

            return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        public ActionResult PCreate(Progress progress)
        {
            TDBContext db = new TDBContext();

            string message = "Saved Successfully";
            bool   status  = true;

            int MID = Convert.ToInt32(TempData["PID"]);


            Progress ac = new Progress
            {
                ReportingDate = progress.ReportingDate,
                Percentage    = progress.Percentage,
                Status        = progress.Status,
                APID          = MID
            };

            db.Progress.Add(ac);
            db.SaveChanges();


            return(Json(new { status = status, message = message, id = db.ActionPoint.Max(x => x.APID) }, JsonRequestBehavior.AllowGet));
        }