示例#1
0
        public async Task <ActionResult> Create(CreateTargetedGroup model)
        {
            var dupName = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Get, $"Setting/Group/NameExists?id={null}&name={model.Name}");

            if (dupName.Data)
            {
                ModelState.AddModelError("Name", "A Group with the same Name already exists in the system");
            }

            if (ModelState.IsValid)
            {
                var response = await WepApiMethod.SendApiAsync <string>(HttpVerbs.Post, $"Setting/Group/Create", model);

                if (response.isSuccess)
                {
                    await LogActivity(Modules.Setting, "Create Target Group: " + response.Data, model);

                    TempData["SuccessMessage"] = "Target Group " + response.Data + " created successfully.";

                    return(RedirectToAction("Index", "Group", new { area = "Setting" }));
                }
                else
                {
                    TempData["SuccessMessage"] = "Failed to create Target Group.";

                    return(RedirectToAction("Index", "Group", new { area = "Setting" }));
                }
            }

            return(View(model));
        }
示例#2
0
        public string Create([FromBody] CreateTargetedGroup model)
        {
            if (ModelState.IsValid)
            {
                var targetgroup = new TargetedGroups
                {
                    Name           = model.Name,
                    Description    = model.Description,
                    MinAge         = model.MinAge,
                    MaxAge         = model.MaxAge,
                    Gender         = model.Gender,
                    MinSalary      = model.MinSalary,
                    MaxSalary      = model.MaxSalary,
                    DMPStatus      = model.DMPStatus,
                    Delinquent     = model.Delinquent,
                    EmploymentType = model.EmploymentType,
                    State          = model.State,
                    CityCode       = model.CityCode,
                    DateCreated    = DateTime.Now,
                    CreatorId      = model.CreatorId,
                    Active         = model.Active
                };

                db.TargetedGroups.Add(targetgroup);
                db.SaveChanges();

                return(model.Name);
            }
            return("");
        }
示例#3
0
        public async Task <ActionResult> Create()
        {
            var resCities = await WepApiMethod.SendApiAsync <List <ReturnTargetedGroupCities> >(HttpVerbs.Get, $"Setting/Group/GetCities");

            if (!resCities.isSuccess)
            {
                return(HttpNotFound());
            }

            var cities = resCities.Data;

            //ViewBag.CityId = new SelectList(cities, "Code", "Name");
            ViewBag.Cities = cities;

            var model = new CreateTargetedGroup();

            return(View(model));
        }