Пример #1
0
        public HttpResponseMessage SelectByProjectId(int projectId)
        {
            ItemsResponse <Act> response = new ItemsResponse <Act>();

            response.Items = ActService.SelectByProjectId(projectId);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #2
0
        public HttpResponseMessage Delete(int id)
        {
            ActService.Delete(id);
            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #3
0
        public async Task <IActionResult> ServiceDelete(int id, int serviceId)
        {
            ActService actService = await _ctx.ActServices.SingleAsync(s => s.Id == serviceId);

            _ctx.ActServices.Remove(actService);
            await _ctx.SaveChangesAsync();

            return(RedirectToAction("edit", new { id = id }));
        }
Пример #4
0
        private void BindActID()
        {
            int       id = Convert.ToInt32(Request.QueryString["id"]);
            DataTable dt = ActService.SelectActID(id);

            if (dt != null && dt.Rows.Count > 0)
            {
                LvActxq.DataSource = dt;
                LvActxq.DataBind();
            }
        }
Пример #5
0
        public HttpResponseMessage Update(ActUpdateRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }
            ActService.Update(model);
            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #6
0
        public HttpResponseMessage Insert(ActAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }
            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = ActService.Insert(model);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("ClientName,SupplierName,DocumentNumber,Date,ClientBin,SupplierBin")] Act act, IEnumerable <ServiceViewModel> service)
        {
            if (ModelState.IsValid)
            {
                if (act.DocumentNumber == null)
                {
                    act.DocumentNumber = await _ctx.Acts.MaxAsync(x => x.DocumentNumber) ?? 0;

                    act.DocumentNumber++;
                }
                else
                {
                    bool alreadyExist = await _ctx.Acts.AnyAsync(x => x.DocumentNumber == act.DocumentNumber);

                    if (alreadyExist)
                    {
                        ModelState.AddModelError("DocumentNumber", "Документ с таким номером уже существует");
                        return(View());
                    }
                }
                foreach (var s in service)
                {
                    if (s.Checked)
                    {
                        ActService actService = new ActService()
                        {
                            Name = s.Name, Price = s.Price, Amount = s.Amount
                        };
                        act.Services.Add(actService);
                    }
                }
                _ctx.Add(act);
                await _ctx.SaveChangesAsync();

                return(RedirectToAction("index"));
            }
            else
            {
                return(View());
            }
        }
Пример #8
0
        public Image GetImg(int type, Guid id)
        {
            OrgService orgService = new OrgService();
            ActService actService = new ActService();
            Image      img;
            string     cacheID = id.ToString();

            if (cache[cacheID] != null)
            {
                img = cache[cacheID] as Image;
                return(img);
            }
            else
            {
                string path = "";
                if (type == 1)
                {
                    path = "E:\\web\\Firewood\\" + orgService.GetPathByID(id);
                }
                else if (type == 2)
                {
                    path = "E:\\web\\Firewood\\" + actService.GetPathByID(id);
                }
                else if (type == 3)
                {
                    path = "E:\\web\\GHY_SSO\\" + AccountStrategy.GetAvatarByUserID(id);
                }

                if (!System.IO.File.Exists(path))
                {
                    return(null);
                }
                else
                {
                    img = Bitmap.FromFile(path);
                    cache.Add(cacheID, img, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null);
                    return(img);
                }
            }
        }