コード例 #1
0
        public ActionResult Jsonindex([Bind(Include = "Id,user_name,email_id,password,role")] Models.user users, string Roles, int?id)
        {
            if (ModelState.IsValid)
            {
                var result = db.users.SingleOrDefault(b => b.Id == id);

                result.role = Roles;
                db.SaveChanges();
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            user urse = db.users.Find(id);

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

            return(View(urse));
        }
コード例 #2
0
 public HttpResponseMessage RecordFeedback([FromBody] FeedbackModel feedback)
 {
     try
     {
         if (feedback == null)
         {
             return(Request.CreateResponse(HttpStatusCode.NoContent, "There was nothing passed"));
         }
         else if (string.IsNullOrEmpty(feedback.Comment) && feedback.Rating == null)
         {
             return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "You have to fill in feedback or at least give a rating"));
         }
         using (var context = new FeedbackEntities())
         {
             context.Feedbacks.Add(new Feedbacks()
             {
                 Id = Guid.NewGuid(),
                 OriginCountryId      = feedback.OriginCountryId,
                 DestinationCountryId = feedback.DestinationCountryId,
                 GroupTypeId          = feedback.GroupTypeId,
                 UserTypeId           = feedback.UserTypeId,
                 TopicId    = feedback.TopicId,
                 Rating     = feedback.Rating,
                 Comment    = feedback.Comment,
                 RecordTime = DateTime.Now
             });
             return(context.SaveChanges() > 0 ?
                    Request.CreateResponse(HttpStatusCode.OK, "Successfully recorded") :
                    Request.CreateResponse(HttpStatusCode.NotModified, "Can not record the feedback"));
         }
     }
     catch (Exception ex)
     {
         new ExceptionHelper().Error(ex, "RecordFeedback");
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
コード例 #3
0
        public ActionResult ReportEorror(feedback post, HttpPostedFileBase Content)
        {
            var field = Session["field"];

            if (Content == null)
            {
                post.date_time     = DateTime.Now;
                post.status        = "submitted";
                post.emp_field     = field.ToString();
                post.employee_name = User.Identity.Name;
                post.type          = "ReportError";
                db.feedbacks.Add(post);
                db.SaveChanges();
            }
            else if (Content != null)
            {
                String FileExt = Path.GetExtension(Content.FileName).ToUpper();

                if (FileExt == ".PNG" || FileExt == ".JPG" && ModelState.IsValid)
                {
                    var fileName = Path.GetFileName(Content.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/Upload"), fileName);
                    var con      = ("~/Content/Upload/" + fileName);
                    Content.SaveAs(path);


                    post.date_time     = DateTime.Now;
                    post.status        = "submitted";
                    post.emp_field     = field.ToString();
                    post.employee_name = User.Identity.Name;
                    post.filename      = fileName;
                    post.filepath      = con;
                    post.type          = "ReportError";
                    db.feedbacks.Add(post);
                    db.SaveChanges();
                }
            }

            return(View());
        }