Ejemplo n.º 1
0
        public ResponseMessage Create(PPKFile entity)
        {
            ResponseMessage response = new ResponseMessage();

            _repository.Create(entity);

            return(response);
        }
Ejemplo n.º 2
0
        public ActionResult PPKComment(HttpPostedFileBase file, PPKCommentViewModel model)
        {
            if (file == null)
            {
                ViewData["ReportId"] = model.ReportId;
                ModelState.AddModelError(string.Empty, "Mohon upload file pendukung.");
                return(View(model));
            }

            var oldReport = _reportLogic.GetById(model.ReportId);
            var comment   = !string.IsNullOrEmpty(oldReport.PPKComment) ? oldReport.PPKComment + "<br />" + model.Comment : model.Comment;

            Report report = new Report()
            {
                PPKComment = comment, Id = model.ReportId
            };

            _reportLogic.UpdatePPKComment(report);

            if (file.ContentLength > 0)
            {
                var fileName = Path.GetFileName(file.FileName);
                var filePath = model.ReportId + "_" + fileName;
                var path     = Path.Combine(Server.MapPath("~/Content/UploadPPK"), filePath);
                file.SaveAs(path);

                PPKFile ppkFile = new PPKFile();
                ppkFile.FileName = fileName;
                ppkFile.ReportId = model.ReportId;

                _ppkFileLogic.Create(ppkFile);
            }

            try
            {
                var msg = new MailMessage();
                msg.To.Add(new MailAddress(ConfigurationManager.AppSettings["AdminEmail"]));
                msg.Subject = "LAPOR-BRANTAS New Comment From PPK";
                msg.Body    = model.Comment;
                msg.From    = new MailAddress("*****@*****.**");

                using (var client = new SmtpClient()
                {
                    Host = "relay-hosting.secureserver.net", Port = 25, EnableSsl = false, UseDefaultCredentials = false
                })
                {
                    client.Send(msg);
                }
            }
            catch (Exception ex)
            {
            }

            return(RedirectToAction("Assigned"));
        }
Ejemplo n.º 3
0
 public ResponseMessage Edit(PPKFile entity)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 public PPKFile Edit(PPKFile entity)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public void Create(PPKFile entity)
 {
     _db.PPKFiles.Add(entity);
     _db.SaveChanges();
 }