Esempio n. 1
0
        public async Task <int> CreateAsync(CompanyAddModel model)
        {
            if (model == null)
            {
                return(ToResponse(0, Errors.invalid_data));
            }
            var company  = _mapper.Map <CompanySql>(model);
            var response = await _rpCompany.CreateAsync(company, _process.User.Id);

            if (response.success)
            {
                if (!string.IsNullOrWhiteSpace(model.LastNote))
                {
                    var note = new NoteAddModel
                    {
                        Content       = model.LastNote,
                        ProfileId     = response.data,
                        ProfileTypeId = (int)NoteType.Company,
                        UserId        = _process.User.Id
                    };
                    await _rpNote.AddNoteAsync(note);
                }
            }
            return(ToResponse(response));
        }
Esempio n. 2
0
        public IActionResult Update(int id)
        {
            Company getCompany = ICompanyServices.GetCompany(id);

            CompanyAddModel companyAddModel = new CompanyAddModel
            {
                ID          = getCompany.CompanyID,
                CompanyName = getCompany.CompanyName
            };

            return(View(companyAddModel));
        }
Esempio n. 3
0
        public async Task <IResultModel> Add(CompanyAddModel model)
        {
            var entity = _mapper.Map <CompanyEntity>(model);
            //if (await _repository.Exists(entity))
            //{
            //return ResultModel.HasExists;
            //}

            var result = await _repository.AddAsync(entity);

            return(ResultModel.Result(result));
        }
Esempio n. 4
0
        public IActionResult Add(CompanyAddModel companyAddModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(companyAddModel));
            }

            else
            {
                Company company = new Company
                {
                    CompanyName = companyAddModel.CompanyName
                };

                ICompanyServices.Add(company);
                return(RedirectToAction("Index", "Company"));
            }
        }
Esempio n. 5
0
        public ActionResult Add(CompanyAddModel model)
        {
            var type = Enumerations.CompanyType.money;

            foreach (int i in Enum.GetValues(typeof(Enumerations.CompanyType)))
            {
                if (((Enumerations.CompanyType)i).ToString().CompareTo(model.Type) == 0)
                {
                    type = (Enumerations.CompanyType)i;
                }
            }
            var field = Enumerations.CompanyField.AutoIndustrija;

            foreach (int i in Enum.GetValues(typeof(Enumerations.CompanyField)))
            {
                if (((Enumerations.CompanyField)i).ToString().CompareTo(model.Field) == 0)
                {
                    field = (Enumerations.CompanyField)i;
                }
            }
            Companys.AddCompany(model.Name, model.Address, model.City, model.Description, model.Email, model.Phone,
                                model.Website, field, type);
            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
 public Task <IResultModel> Add(CompanyAddModel model)
 {
     return(_service.Add(model));
 }
Esempio n. 7
0
        public async Task <IActionResult> CreateAsync([FromBody] CompanyAddModel model)
        {
            var result = await _bizCompany.CreateAsync(model);

            return(ToResponse(result));
        }