Esempio n. 1
0
 public ActionResult Create(CompanyTBL companyTBL)
 {
     if (ModelState.IsValid)
     {
         _companyService.Add(companyTBL);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
Esempio n. 2
0
        public IHttpActionResult PostCompany(AddCompanyRequest addCompanyRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var company = new Company
            {
                Name        = addCompanyRequest.Name,
                Tva         = addCompanyRequest.Tva,
                Headquarter = new Address
                {
                    Address1 = addCompanyRequest.Address1,
                    Locality = addCompanyRequest.Locality
                }
            };

            _companyService.Add(company);
            return(CreatedAtRoute(
                       "DefaultApi",
                       new { id = company.Id },
                       new CompanyResult
            {
                Id = company.Id,
                Name = company.Name,
                Tva = company.Tva,
                HeadquarterAddress = new AddressResult
                {
                    Id = company.Headquarter.Id,
                    Address1 = company.Headquarter.Address1,
                    Locality = company.Headquarter.Locality,
                }
            }));
        }
        public ActionResult AddUser(NewUserViewModel newUser)
        {
            var company = new Company
            {
                DoingBusinessAs   = newUser.CompanyName,
                LegalName         = newUser.CompanyName,
                NumberOfEmployees = newUser.NumberOfEmployees
            };
            var user = new User
            {
                FullName     = newUser.FullName,
                Title        = newUser.Title,
                EmailAddress = newUser.Email,
                PhoneNumber  = newUser.PhoneNumber
            };

            try
            {
                _companyService.Add(company);
                _userService.Add(user);

                return(new HttpStatusCodeResult(HttpStatusCode.Created));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Esempio n. 4
0
        private bool InsertCompanyToDb(DMCompany company, Guid userGuid)
        {
            var entity = MapCompanyToCoreCompany(company, userGuid);

            _companyService.Add(entity);
            return(true);
        }
 public ApiResponseViewModel Create(Company obj)
 {
     if (HttpContext.Current.Session["UserLogged"] == null)
     {
         return(CommonConstants.accessDenied);
     }
     return(_companyService.Add(obj));
 }
 public async Task <ActionResult <CompanyViewModel> > Add(CompanyViewModel companyViewModel)
 {
     if (!ModelState.IsValid)
     {
         return(CustomResponse(ModelState));
     }
     return(CustomResponse(await _companyService.Add(companyViewModel)));
 }
Esempio n. 7
0
        public async Task <ActionResult <CompanyViewModel> > Add(CompanyViewModel companyViewModel)
        {
            var company = _mapper.Map <Company>(companyViewModel);

            await _companyService.Add(company);

            return(NoContent());
        }
        public async Task <IActionResult> Index()
        {
            var company = await _companyService.Add(new Company { Address = "as", Name = "asd" });

            var aa = await _companyService.GetAll();

            return(View(aa));
        }
Esempio n. 9
0
        public Company Create(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("Company name is null");
            }

            return(_companyService.Add(name));
        }
        public ActionResult Companies_Create([DataSourceRequest] DataSourceRequest request, Company company)
        {
            if (ModelState.IsValid)
            {
                _companyService.Add(company);
            }

            return(Json(new[] { company }.ToDataSourceResult(request, ModelState)));
        }
Esempio n. 11
0
        public async Task <IActionResult> CompanyControlAdd(CompanyViewModal companyViewModal)
        {
            string filenameadd = DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace(" ", "_").Replace(":", "_").Replace(".", "_").Replace(" ", "_").Replace("/", "_").Replace("\\", "_");
            string images      = Path.Combine(_environment.WebRootPath, "images/CompanyImages");
            string imagesPath  = filenameadd + companyViewModal.ImageFile.FileName;

            if (companyViewModal.ImageFile.Length > 0)
            {
                await using (var fileStream = new FileStream(Path.Combine(images,
                                                                          imagesPath), FileMode.Create))
                {
                    await companyViewModal.ImageFile.CopyToAsync(fileStream);
                }
            }
            companyViewModal.CompanyImage = imagesPath;
            using (var client = new HttpClient())
            {
                var response = await client.GetAsync(string.Format("http://{0}:{1}/CompanyControlTax?TaxNo={2}&Name={3}", _serviceModal.IpAddress, _serviceModal.Port, companyViewModal.CompanyTaxNo, companyViewModal.CompanyName));

                var model = JsonConvert.DeserializeObject <IEnumerable <ServiceCompanyControl> >(
                    response.Content.ReadAsStringAsync().Result);
                int companyType = 0;
                if (model != null)
                {
                    foreach (var item in model)
                    {
                        companyType = item.CompanyType;
                    }
                }
                Company company = new Company
                {
                    CompanyName     = companyViewModal.CompanyName,
                    CompanyAdress   = companyViewModal.CompanyAdress,
                    CompanyCity     = companyViewModal.CompanyCity,
                    CompanyDistrict = companyViewModal.CompanyDistrict,
                    CompanyMail     = companyViewModal.CompanyMail,
                    CompanyPhone    = companyViewModal.CompanyPhone,
                    CompanyType     = companyType,
                    UserId          = Convert.ToInt32(HttpContext.Session.GetString("UserId"))
                };
                _companyService.Add(company);
                company = _companyService.GetAll().OrderByDescending(x => x.CompanyId).FirstOrDefault();

                if (companyType == 0)
                {
                    return(RedirectToAction("CarParkAdd", "CarPark", new { companyId = company?.CompanyId }));
                }
                else if (companyType == 1)
                {
                    return(RedirectToAction("PetrolStationAdd", "PetrolStation", new { companyId = company?.CompanyId }));
                }
                else
                {
                    return(RedirectToAction("PharmacyGetList", "Pharmacy"));
                }
            }
        }
        public HttpResponseMessage Post(HttpRequestMessage req, [FromBody] Company value)
        {
            HttpResponseMessage result = null;
            string userId = null;

            #region InputCheck
            try
            {
                if (value == null)
                {
                    result         = Request.CreateResponse(HttpStatusCode.Unauthorized);
                    result.Content = new StringContent(JsonConvert.SerializeObject("Invalid Parameters"), Encoding.UTF8, "application/json");
                    return(result);
                }
                string token = req.Headers.Authorization.ToString();
                userId = utils.checkToken(token);
            }
            catch (Exception tEx)
            {
                result         = Request.CreateResponse(HttpStatusCode.Unauthorized);
                result.Content = new StringContent(JsonConvert.SerializeObject("Unauthorized access"), Encoding.UTF8, "application/json");
                return(result);
            }
            try
            {
                if (companyService.GetById(value.Id) != null)
                {
                    result         = Request.CreateResponse(HttpStatusCode.Found);
                    result.Content = new StringContent(JsonConvert.SerializeObject("Company already exist"), Encoding.UTF8, "application/json");
                    return(result);
                }
            }
            catch (System.Exception tEx)
            {
                System.Exception raisedException = tEx;
                result         = Request.CreateResponse(HttpStatusCode.InternalServerError);
                result.Content = new StringContent(JsonConvert.SerializeObject(raisedException), Encoding.UTF8, "application/json");
            }

            #endregion

            try
            {
                value.Id = Guid.NewGuid().ToString();
                companyService.Add(value);
                result         = Request.CreateResponse(HttpStatusCode.OK);
                result.Content = new StringContent(JsonConvert.SerializeObject(value),
                                                   Encoding.UTF8, "application/json");
            }
            catch (System.Exception tEx)
            {
                System.Exception raisedException = tEx;
                result         = Request.CreateResponse(HttpStatusCode.InternalServerError);
                result.Content = new StringContent(JsonConvert.SerializeObject(raisedException.ToString()), Encoding.UTF8, "application/json");
            }
            return(result);
        }
Esempio n. 13
0
 public IActionResult Create(Company company)
 {
     if (ModelState.IsValid)
     {
         _context.Add(company);
         return(RedirectToAction("Index"));
     }
     return(View(company));
 }
 public ActionResult Create([Bind(Include = "Id,Name,OrganizationNumber,Notes")] Company company)
 {
     if (ModelState.IsValid)
     {
         company.Id = Guid.NewGuid();
         companyService.Add(company);
         return(RedirectToAction("Index"));
     }
     return(View(company));
 }
        public IActionResult Create([Bind("CompanyId,CompanyName,Address,Status")] m_cls_Company_D company)
        {
            if (ModelState.IsValid)
            {
                _companydb.Add(company);
                return(RedirectToAction(nameof(Index)));
            }

            return(View(company));
        }
        public IActionResult Add(Company company)
        {
            var result = companyService.Add(company);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Esempio n. 17
0
        public ActionResult Create(CompanyInfo item)
        {
            if (ModelState.IsValid)
            {
                _db.Add(item);
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Esempio n. 18
0
        public IActionResult Add(Company cast)
        {
            var result = _companyService.Add(cast);

            if (result.Success)
            {
                return(Ok(result.Message));
            }
            return(BadRequest(result.Message));
        }
Esempio n. 19
0
        public async Task <IActionResult> Post([FromBody] Company company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await _companyService.Add(company);

            return(Ok());
        }
Esempio n. 20
0
 public Company Add(CompanyInputModel company)
 {
     return(_companyService.Add(
                new Company
     {
         CompanyName = company.CompanyName,
         CompanyAdress = company.CompanyAdress,
         ContactName = company.ContactName
     }
                ));
 }
Esempio n. 21
0
 public async Task <ActionResult <ReturnResponse <Company> > > AddCompany(CompanyAdd inVal)
 {
     try
     {
         return(await _service.Add(inVal));
     }
     catch (Exception ex)
     {
         return(NotFound(ex.Message));
     }
 }
Esempio n. 22
0
 public async Task <IActionResult> AddCompany(CompanyViewModel viewModel)
 {
     try
     {
         return(Ok(await _companyService.Add(viewModel)));
     }
     catch (Exception ex)
     {
         throw ex.InnerException;
     }
 }
 public ActionResult <Company> Add([FromBody] Company company)
 {
     try
     {
         return(Ok(_companyService.Add(company)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 24
0
 public JavaScriptResult Create(CompanyViewModel comvm)
 {
     try
     {
         _companyService.Add(Mapper.Map <Company>(comvm));
         return(JavaScript($"ShowResult('{"Data saved successfully."}','{"success"}','{"redirect"}','{"/CPanel/Company"}')"));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }
Esempio n. 25
0
        public ActionResult AdminRegister(RegisterAdminAndCompanyViewModel model)
        {
            ViewBag.Countries = _countryService.GetAll();
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Password != model.RePassword)
                    {
                        ViewBag.Message = "Şifreler uyuşmuyor";
                        return(View("AdminRegister"));
                    }
                    else
                    {
                        Company company = new Company();
                        company.About       = model.About;
                        company.CompanyName = model.CompanyName;
                        company.Freight     = model.Freight;
                        company.LogoPath    = model.LogoPath;
                        company.TaxNumber   = model.TaxNumber;
                        company.Phone       = model.Phone;
                        bool resultCompany = _companyService.Add(company);
                        if (!resultCompany)
                        {
                            ViewBag.Message = "Şirket eklemede hata meydana geldi!";
                        }

                        Admin admin = new Admin();
                        admin.AdminRole = _adminRoleService.GetAdminRoleByName("Company Admin");
                        admin.EMail     = model.EMail;
                        admin.Password  = model.Password;
                        admin.Username  = model.Username;
                        admin.Company   = company;
                        bool resultAdmin = _adminService.Add(admin);
                        if (!resultAdmin)
                        {
                            ViewBag.Message = "Şirket eklemede hata meydana geldi!";
                        }

                        return(RedirectToAction("AdminLogin", "Login"));
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View("AdminRegister"));
                }
            }
            else
            {
                return(View());
            }
        }
        public async Task <IActionResult> Post([FromBody] Company company)
        {
            //if (await _companyService.Exists(x => x.Id == company.Id))
            if (await _companyService.Exists(CompanyQueries.FindById(company.Id.Value)))
            {
                return(StatusCode(StatusCodes.Status406NotAcceptable, new { message = "Company Exists" }));
            }

            var result = await _companyService.Add(company);

            return(StatusCode(StatusCodes.Status201Created, new { company = result }));
        }
Esempio n. 27
0
 public IActionResult CreateCompany(Company company)
 {
     if (ModelState.IsValid)
     {
         companyService.Add(company);
     }
     else
     {
         return(RedirectToAction("CreateCompany"));
     }
     return(RedirectToAction("Company"));
 }
 public IActionResult Post([FromBody] CompanyApiModel newCompany)
 {
     try
     {
         Company company = _companyService.Add(newCompany.ToDomainModel());
         return(Ok(company.ToApiModel()));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("AddCompany", ex.Message);
         return(BadRequest(ModelState));
     }
 }
Esempio n. 29
0
        public async Task <IActionResult> Create(CompanyViewModel companyViewModel)
        {
            if (companyViewModel.Phone != "")
            {
                companyViewModel.Phone = companyViewModel.Phone.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "");
            }

            if (!ModelState.IsValid)
            {
                return(View(companyViewModel));
            }

            var company = _mapper.Map <Company>(companyViewModel);
            await _companyService.Add(company);

            if (!IsValidOperation())
            {
                return(View(companyViewModel));
            }

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 30
0
        public ActionResult <Company> Add([FromBody] AddNewCompanyRequest newCompany)
        {
            try
            {
                Company company = _mapper.Map <Company>(newCompany);

                return(_company.Add(company));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }