예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Sourse,Phone,StatusName,StartPrice,EndPrice,WhenCreateTime,ManagerName,DataBirdClient,SendDateTime,NameOfClient,TownAndAdressName,NumberOfPostInTown,TtnFromPost,ReasonOtkas,DateWhenClientTakeOrder,DateToCall")] LeadObereg leadObereg)
        {
            if (id != leadObereg.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(leadObereg);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LeadOberegExists(leadObereg.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(leadObereg));
        }
예제 #2
0
        public async Task <IActionResult> PostLead([FromBody] LeadObereg leadObereg)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                leadObereg.WhenCreateTime = DateTime.UtcNow.AddHours(3);
                if (_context.Lead.Any(a => a.Phone == leadObereg.Phone))
                {
                    leadObereg.StatusName = StatusName.Дубль;
                }

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
                    leadObereg.Name + "  " + leadObereg.Phone + " " + leadObereg.StartPrice + " " + leadObereg.Sourse);
                var telegram = request.GetResponse();
                leadObereg.DataBirdClient          = DateTime.Now;
                leadObereg.DateToCall              = DateTime.Now;
                leadObereg.DateWhenClientTakeOrder = DateTime.Now;
                leadObereg.SendDateTime            = DateTime.Now;;
                _context.Lead.Add(leadObereg);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetLead", new { id = leadObereg.Id }, leadObereg));
            }
            catch (Exception e)
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
                    "https://api.telegram.org/bot844755827:AAE_rbHA55jgSpb_CMQeTPDRaY6eAU6_nSI/sendMessage?chat_id=-345559666&text=" +
                    e.ToString());
                request.GetResponse();
                throw;
            }
        }
예제 #3
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [FromForm] LeadObereg model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }


            if (ModelState.IsValid)
            {
                try
                {
                    _context.Lead.Update(model);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LeadCrmExists(model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Sourse,Phone,StatusName,StartPrice,EndPrice,WhenCreateTime,ManagerName,DataBirdClient,SendDateTime,NameOfClient,TownAndAdressName,NumberOfPostInTown,TtnFromPost,ReasonOtkas,DateWhenClientTakeOrder,DateToCall")] LeadObereg leadObereg)
        {
            if (ModelState.IsValid)
            {
                _context.Add(leadObereg);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(leadObereg));
        }