示例#1
0
        public JsonResult ReserveMarksRequest()
        {
            Stream req = Request.InputStream;

            req.Seek(0, SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();

            ReserveMarksRequest input = null;

            try {
                input = JsonConvert.DeserializeObject <ReserveMarksRequest>(json);
                //JavaScriptSerializer ser = new JavaScriptSerializer();
                //input = ser.Deserialize<ReserveMarksRequest>(json);
                input.Status = "Reserved";

                //request to base
                string location             = input.Location;
                string document             = input.Document;
                IEnumerable <string> ListID = from material in input.Materials
                                              select material.Id;
                IEnumerable <string> ListBatch = from material in input.Materials
                                                 select material.Batch;

                IEnumerable <ReserveMarksResponse> result = repo.Get(location, document, ListID, ListBatch);
            } catch {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(Json(new { Status = "BAD", Data = "" }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { Status = "SUCCES", Data = new[] { "Vadim", "Anna" } }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public string ReserveMarksRequest()
        {
            Stream req = Request.InputStream;

            req.Seek(0, SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();

            ReserveMarksRequest inputRequest = null;
            Stopwatch           sw           = Stopwatch.StartNew();

            try {
                inputRequest = JsonConvert.DeserializeObject <ReserveMarksRequest>(json);

                //request to base
                string location = inputRequest.Location;
                string document = inputRequest.Document;
                IEnumerable <string> artikuls = from material in inputRequest.Materials
                                                select material.Artikul;
                IEnumerable <string> batches = from material in inputRequest.Materials
                                               select material.Batch;

                Arrival currentDoc = repository.GetMarks(location, document, artikuls, batches, inputRequest);
                if (currentDoc == null)
                {
                    return(null);
                }
                else
                {
                    currentDoc.Result = "Ok";
                    return(JsonConvert.SerializeObject(currentDoc));
                }
            }
            catch (Exception e) {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                string error = e.Message;
                return("{\"Result\":\"Error\"}");
            }
        }