Exemplo n.º 1
0
        public async Task <IActionResult> PutInsertedInfo([FromRoute] int id, [FromBody] InsertedInfo insertedInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != insertedInfo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(insertedInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InsertedInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostInsertedInfo([FromBody] InsertedInfo insertedInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            insertedInfo.UpDateTime = DateTime.UtcNow.AddHours(3);
            _context.AdditionalInfos.Add(insertedInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetInsertedInfo", new { id = insertedInfo.Id }, insertedInfo));
        }
Exemplo n.º 3
0
        // GET: LeadCrms/Details/5

        /*  public async Task<IActionResult> Details(int? id)
         * {
         *    if (id == null)
         *    {
         *        return NotFound();
         *    }
         *
         *    var leadCrm = await Task.Run(() => leadCrmSystem.GenerateLeadCrm(_context).FirstOrDefault(m=>m.Id ==id));
         *    //var leadCrm = await _context.LeadCrm.FirstOrDefaultAsync(m => m.Id == id);
         *    if (leadCrm == null)
         *    {
         *        return NotFound();
         *    }
         *    return View(leadCrm);
         * }
         */
        // GET: LeadCrms/Create

        /* public IActionResult Create()
         * {
         *   return View();
         * }*/

        // POST: LeadCrms/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.

        /* [HttpPost]
         * [ValidateAntiForgeryToken]
         * public async Task<IActionResult> Create([Bind("Id")] LeadCrm leadCrm)
         * {
         *   if (ModelState.IsValid)
         *   {
         *       _context.Add(leadCrm);
         *       await _context.SaveChangesAsync();
         *       return RedirectToAction(nameof(Index));
         *   }
         *   return View(leadCrm);
         * }
         */
        // GET: LeadCrms/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var leadCrm = leadCrmSystem.GenerateLeadCrm(_context, (int)id);

            if (leadCrm == null)
            {
                return(NotFound());
            }

            if (leadCrm.ListInsert == null || leadCrm.ListInsert?.Count == 0)
            {
                var insdertnewcoment = new InsertedInfo();
                insdertnewcoment.Comment    = "Менеджер начала обрабатывать лид";
                insdertnewcoment.UpDateTime = DateTime.UtcNow.AddHours(3);
                insdertnewcoment.LeadId     = id.Value;
                _context.AdditionalInfos.Add(insdertnewcoment);
                _context.SaveChanges();
                leadCrm.ListInsert = new List <InsertedInfo>()
                {
                    insdertnewcoment
                };
            }

            ViewBag.comments = leadCrm.ListInsert;

            if (leadCrm.Lead.SendDateTime.ToString() == "0001-01-01 00:00:00.0000000")
            {
                leadCrm.Lead.SendDateTime = DateTime.Now;
            }

            if (leadCrm.Lead.DataBirdClient.ToString() == "0001-01-01 00:00:00.0000000")
            {
                leadCrm.Lead.DataBirdClient = DateTime.Now;
            }



            return(View(leadCrm.Lead));
        }