Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Class @class)
        {
            if (id != @class.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@class);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClassExists(@class.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@class));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ClassId,Priority,DueDate,Title,Notes,IsComplete")] Assignment assignment)
        {
            if (id != assignment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(assignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssignmentExists(assignment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassId"] = new SelectList(_context.Classes, "Id", "Id", assignment.ClassId);
            return(View(assignment));
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> Add(BusinessEntityAddViewModel model, int?agentId)
        {
            if (ModelState.IsValid)
            {
                /*
                 * Flight APIs, Agent Type, Markup Plan is skipped
                 * Because of not matching with Business Entity Data
                 */
                //Edit
                if (agentId != null)
                {
                    var dbAgent = await _context.BusinessEntities.FirstOrDefaultAsync(f => f.BusinessId == agentId);

                    if (dbAgent == null)
                    {
                        return(Json(new { success = false, message = "Can't find this agent" }));
                    }
                    dbAgent = _mapper.Map(model, dbAgent);
                    dbAgent.UpdatedOnUtc = DateTime.UtcNow;

                    try
                    {
                        _context.Update(dbAgent);
                        await _context.SaveChangesAsync();
                    }
                    catch (Exception e)
                    {
                        //log
                        Console.WriteLine(e.Message);
                        return(Json(new { success = false, message = "Can't update the agent" }));
                    }

                    return(Json(new { success = true, message = "Successfully Updated Agent" }));
                }


                var businessEntity = new BusinessEntities
                {
                    State         = model.State,
                    Balance       = model.Balance,
                    City          = model.City,
                    Code          = model.Code,
                    ContactPerson = model.ContactPerson,
                    Country       = model.Country,
                    CreatedOnUtc  = DateTime.UtcNow,
                    Email         = model.Email,
                    Mobile        = model.Mobile,
                    Name          = model.Name,
                    Phone         = model.Phone,
                    ReferredBy    = model.ReferredBy,
                    SMTPPassword  = model.SMTPPassword,
                    SMTPPort      = model.SMTPPort,
                    SMTPServer    = model.SMTPServer,
                    SMTPUsername  = model.SMTPUsername,
                    Status        = model.Status,
                    Street        = model.Street,
                    UpdatedOnUtc  = DateTime.UtcNow,
                    SecurityCode  = model.SecurityCode,
                    Zip           = model.Zip,
                    MarkupPlanId  = model.MarkupPlanId,
                    Logo          = await UploadFile(model.LogoFile, model.Name),
                };
                await _context.BusinessEntities.AddAsync(businessEntity);

                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Successfully Added Agent" }));
            }



            return(Json(new { success = false, message = "Something Wrong please check all Inputs" }));
        }