Exemplo n.º 1
0
 public bool DeleteCompany(Models.Company value)
 {
     try
     {
         if (value.Id != 0)
         {
             Models.Company temp = new Models.Company
             {
                 Id          = value.Id,
                 DeletedTime = DateTime.Now
             };
             var resval = CreatingOrUpdatingCompany(temp);
             return(resval);
         }
         else
         {
             throw new Helper.RepositoryException(UpdateResultType.INVALIDEARGUMENT);
         }
     }
     catch (SystemException ex)
     {
         Console.WriteLine(string.Format("An error occurred: {0}", ex.ToString()));
         throw new Helper.RepositoryException(ex.Message, UpdateResultType.ERROR);
     }
 }
Exemplo n.º 2
0
        public async Task CreateAsync(Models.Company input)
        {
            var list = new List <Models.Company>(Companies);

            list.Add(input);
            Companies = list;
        }
Exemplo n.º 3
0
 public void EditCompany(Models.Company company, Guid id)
 {
     if (company.IsValid())
     {
         _companyRepository.EditCompany(company, id);
     }
 }
Exemplo n.º 4
0
 private void OnCompanyItemTapped(object sender, ItemTappedEventArgs e)
 {
     Models.Company company = e.Item as Models.Company;
     listCompany.SelectedItem  = null;
     Helper.Helper.CompanyName = company.CompanyName;
     dashboardViewModel.GoToChildrenMissingCommand.Execute(company.CompanyId);
 }
Exemplo n.º 5
0
        public static Models.Company Company(System.Json.JsonValue json)
        {
            System.Json.JsonValue jsonR = json;
            Console.WriteLine("jsonResult: " + jsonR["Email"]);
            var u = new Models.Company();

            u.Id                  = Java.Lang.Long.ParseLong(json["Id"].ToString());
            u.Email               = jsonR["Email"];
            u.Adress              = jsonR["Adress"];
            u.CompanyAbout        = jsonR["CompanyAbout"];
            u.CompanyFullName     = jsonR["CompanyFullName"];
            u.Phone               = Java.Lang.Long.ParseLong(json["Phone"].ToString());
            u.CompanyLogo         = jsonR["CompanyLogo"];
            u.CompanyName         = jsonR["CompanyName"];
            u.ContactEmail        = jsonR["ContactEmail"];
            u.Facebook            = jsonR["Facebook"];
            u.Instagram           = jsonR["Instagram"];
            u.ForName_And_SurName = jsonR["ForName_And_SurName"];
            u.NIP                 = jsonR["NIP"];
            u.ProductsAbout       = jsonR["ProductsAbout"];
            u.Snapchat            = jsonR["Snapchat"];
            u.StandPhoto          = jsonR["StandPhoto"];
            u.Photo1              = jsonR["Photo1"];
            u.Photo2              = jsonR["Photo2"];
            u.Photo3              = jsonR["Photo3"];
            u.Photo4              = jsonR["Photo4"];
            u.Photo5              = jsonR["Photo5"];
            u.UserPhone           = Java.Lang.Long.ParseLong(json["Phone"].ToString());
            u.www                 = jsonR["www"];
            u.Youtube             = jsonR["Youtube"];
            return(u);
        }
Exemplo n.º 6
0
        public void Remove(Models.Company toRemove)
        {
            var list = new List <Models.Company>(Companies);

            list.Remove(toRemove);
            Companies = list;
        }
Exemplo n.º 7
0
 public ActionResult DeleteConfirmed(int id)
 {
     Models.Company company = db.Companies.Find(id);
     db.Companies.Remove(company);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 8
0
        public Models.Company ReturnCompanyFromDB(Models.Company company)
        {
            string queryString = "SELECT * FROM dbo.COMPANIES WHERE CompanyEmail = @Email and Password = @Password";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                Models.Company returnedCompany = new Models.Company();
                SqlCommand     command         = new SqlCommand(queryString, connection);
                command.Parameters.Add("@Email", System.Data.SqlDbType.VarChar, 50).Value    = company.CompanyEmail;
                command.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50).Value = company.Password;
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            returnedCompany.ID           = reader.GetInt32(0);
                            returnedCompany.CompanyEmail = reader.GetString(1);
                            returnedCompany.Password     = reader.GetString(2);
                            returnedCompany.CompanyName  = reader.GetString(3);
                        }
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return(returnedCompany);
            }
        }
        public async Task <bool> UpdateAsync(int id, Models.Company updated)
        {
            var fromDb = await _db.Companies.Include(c => c.Employees).FirstOrDefaultAsync(c => c.Id == id);

            if (fromDb == null)
            {
                return(false);
            }

            if (fromDb.Employees != null)
            {
                foreach (var employee in fromDb.Employees)
                {
                    _db.Remove(employee);
                }
            }
            foreach (var employee in updated.Employees)
            {
                await _db.AddAsync(employee);
            }
            fromDb.Employees = updated.Employees;

            fromDb.Name = updated.Name;
            fromDb.EstablishmentYear = updated.EstablishmentYear;
            return(true);
        }
        public ActionResult Add(HttpPostedFileBase filee, Models.Company c)
        {
            if (filee != null)
            {
                using (BinaryReader br = new BinaryReader(filee.InputStream))
                {
                    bytes = br.ReadBytes(filee.ContentLength);
                }
            }
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into Company(id,companyName,ceoName,totalProject,pendingProject,email,headquarters,phoneNumber,companyType,image,active) values(@id,@companyName,@ceoName,@totalProject,@pendingProject,@email,@headquarters,@phoneNumber,@companyType,@image,@active)", con);

            cmd.Parameters.AddWithValue("@id", c.id);
            cmd.Parameters.AddWithValue("@companyName", c.companyName);
            cmd.Parameters.AddWithValue("@ceoName", c.ceoName);
            cmd.Parameters.AddWithValue("@totalProject", c.totalProjects);
            cmd.Parameters.AddWithValue("@pendingProject", c.pendingProjects);
            cmd.Parameters.AddWithValue("@email", c.email);
            cmd.Parameters.AddWithValue("@headQuarters", c.headquarters);
            cmd.Parameters.AddWithValue("@phoneNumber", c.phoneNumber);
            cmd.Parameters.AddWithValue("@companyType", c.companyType);
            cmd.Parameters.AddWithValue("@image", bytes);
            cmd.Parameters.AddWithValue("@active", 1);
            cmd.ExecuteNonQuery();
            return(RedirectToAction("Companies"));
        }
Exemplo n.º 11
0
        public IActionResult Get(int id)
        {
            try
            {
                Models.Company dt    = Company.Read(id);
                var            reval = dt != null?StatusCode(StatusCodes.Status200OK, dt) : (IActionResult)StatusCode(StatusCodes.Status204NoContent);

                return(reval);
            }
            catch (Helper.RepositoryException ex)
            {
                switch (ex.Type)
                {
                case UpdateResultType.SQLERROR:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Internal Server Error"));

                case UpdateResultType.INVALIDEARGUMENT:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status409Conflict, "Conflict"));

                case UpdateResultType.ERROR:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status400BadRequest, "Bad Request"));

                default:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status406NotAcceptable, "Not Acceptable"));
                }
            }
        }
Exemplo n.º 12
0
        private Customer CreateCustomer(Models.Company company, string broker, CompanyDTO oldCompany)
        {
            _loadCount.AddRead(EntityType.Customer);

            Models.Company brokerCompany;
            _brokersByName.TryGetValue(broker, out brokerCompany);

            var customer = new Customer
            {
                Id       = company.Id,
                Company  = company,
                BrokerId = brokerCompany != null ? brokerCompany.Id : -1,
                Notes    = CreateCustomerNotes(company, oldCompany).ToList()
            };

            if (customer.BrokerId == -1)
            {
                List <Customer> customers;
                if (!_customersPendingBroker.TryGetValue(broker, out customers))
                {
                    _customersPendingBroker.Add(broker, customers = new List <Customer>());
                }
                customers.Add(customer);
            }

            return(customer);
        }
Exemplo n.º 13
0
 public ActionResult Index()
 {
     Models.Company mCompany = Entities.Companies.FirstOrDefault(m => m.CompanyId > 0);
     ViewBag.Company   = mCompany != default(Models.Company) ? mCompany.Title : "No hay compañías";
     ViewBag.CompanyId = mCompany != default(Models.Company) ? mCompany.CompanyId : 0;
     return(View());
 }
Exemplo n.º 14
0
        public bool RegisterCompany(Models.Company company)
        {
            Random rnd = new Random();

            bool success = false;

            string queryString = "INSERT INTO dbo.COMPANIES (Id, CompanyEmail, Password, CompanyName) VALUES (@Id, @CompanyEmail, @Password, @CompanyName)";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@Id", rnd.Next(100000, 99999999));
                command.Parameters.AddWithValue("@CompanyEmail", company.CompanyEmail);
                command.Parameters.AddWithValue("@Password", company.Password);
                command.Parameters.AddWithValue("@CompanyName", company.CompanyName);

                connection.Open();
                int result = command.ExecuteNonQuery();

                if (result < 0)
                {
                    Console.WriteLine("Error inserting");
                }
                else
                {
                    success = true;
                }
            }

            return(success);
        }
Exemplo n.º 15
0
        public IActionResult Post([FromBody] Models.Company value)
        {
            try
            {
                bool dt    = Company.Create(value);
                var  reval = dt ? StatusCode(StatusCodes.Status200OK) : (IActionResult)StatusCode(StatusCodes.Status204NoContent);
                return(reval);
            }
            catch (Helper.RepositoryException ex)
            {
                switch (ex.Type)
                {
                case UpdateResultType.SQLERROR:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Internal Server Error"));

                case UpdateResultType.INVALIDEARGUMENT:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status409Conflict, "Conflict"));

                case UpdateResultType.ERROR:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status400BadRequest, "Bad Request"));

                default:
                    logger.Error(ex.ErrorMsg);
                    return(StatusCode(StatusCodes.Status406NotAcceptable, "Not Acceptable"));
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Create a Company
        /// </summary>
        /// <param name="company"></param>
        /// <returns>The Created Company</returns>
        public async Task <Models.Company> CreateCompany(Models.Company company)
        {
            await dbContext.Companys.AddAsync(company);

            dbContext.SaveChanges();
            return(await this.GetCompanyByISIN(company.ISIN));
        }
Exemplo n.º 17
0
        public bool Create(Models.Company value)
        {
            try
            {
                if (value.Name != null)
                {
                    Models.Company temp = new Models.Company {
                        Id          = -1,
                        DeletedTime = value.DeletedTime = null,
                        Name        = value.Name
                    };

                    var resval = CreatingOrUpdatingCompany(value);
                    return(resval);
                }
                else
                {
                    throw new Helper.RepositoryException(UpdateResultType.INVALIDEARGUMENT);
                }
            }
            catch (Exception ex)
            {
                throw new Helper.RepositoryException(ex.Message, UpdateResultType.ERROR);
            }
        }
Exemplo n.º 18
0
        public bool AuthenticateCompanyInDB(Models.Company company)
        {
            bool success = false;

            Debug.WriteLine(company.CompanyEmail);
            Debug.WriteLine(company.Password);
            string queryString = "SELECT * FROM dbo.COMPANIES WHERE CompanyEmail = @email and Password = @password";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.Add("@email", System.Data.SqlDbType.VarChar, 50).Value    = company.CompanyEmail;
                command.Parameters.Add("@password", System.Data.SqlDbType.VarChar, 50).Value = company.Password;
                try
                {
                    connection.Open();
                    Debug.WriteLine("in here");
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        success = true;
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }
            return(success);
        }
Exemplo n.º 19
0
 public Company(Models.Company company)
 {
     Id          = company.Id;
     CreatedDate = company.CreatedDate;
     Name        = company.Name;
     Address     = company.Address;
     Phone       = company.Phone;
 }
Exemplo n.º 20
0
        private void OnImageButtonClicked(object sender, System.EventArgs e)
        {
            ImageButton button = sender as ImageButton;

            Models.Company company = button.BindingContext as Models.Company;
            Helper.Helper.CompanyName = company.CompanyName;
            dashboardViewModel.GoToChildrenMissingCommand.Execute(company.CompanyId);
        }
Exemplo n.º 21
0
        private bool CanDelete(Guid id)
        {
            var company = new Models.Company {
                Id = id
            };
            var validator = new DeleteCompanyValidation().Validate(company);

            return(validator.IsValid);
        }
Exemplo n.º 22
0
 public ActionResult Company(Models.Company _c)
 {
     ViewModel.Company.Company company = new ViewModel.Company.Company();
     if (ModelState.IsValid)
     {
         ViewBag.msg = company.Save(_c, 0);
     }
     return(View(company.Get(0)));
 }
Exemplo n.º 23
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = Input.Email,
                    Email     = Input.Email,
                    FirstName = Input.FirstName,
                    LastName  = Input.Lastname,
                    // CompanyId = Input.CompanyName
                };
                Models.Company selectedCompany =
                    _context.Company.FirstOrDefault(c => c.Name == SelectedCompanyName);
                user.Corporation = selectedCompany.CompanyId;
                // attach company
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Exemplo n.º 24
0
        public async Task <BaseResponse> CreateProduct(CreateProductRequest request, int UserID, int CompanyID)
        {
            BaseResponse response = new BaseResponse();

            Models.Product  product  = null;
            Models.Company  company  = null;
            Models.Category category = null;
            Models.Property property = null;

            category = request.CategoryID.HasValue ?
                       await this.context.Categories.Where(a => a.ID.Equals(request.CategoryID)).FirstOrDefaultAsync() :
                       null;

            try
            {
                await context.Database.BeginTransactionAsync();

                product            = new Models.Product();
                product.Name       = request.Name;
                product.Barcode    = request.Barcode;
                product.Price      = request.Price;
                product.TaxRate    = request.TaxRate;
                product.TotalPrice = Decimal.Add(product.Price, Decimal.Multiply(product.Price, Decimal.Divide(product.TaxRate, 100)));
                product.CategoryID = category != null ? (int?)category.ID : null;
                product.CompanyID  = CompanyID;

                context.Products.Add(product);
                await context.SaveChangesAsync();

                if (request.Properties != null && request.Properties.Count > 0)
                {
                    foreach (dto.Models.Property dtoProp in request.Properties)
                    {
                        property           = new Models.Property();
                        property.Name      = dtoProp.Name;
                        property.ProductID = product.ID;
                        property.Value     = dtoProp.Value;
                        property.Type      = dtoProp.Type != null?sharedRepository.PropertyTypeConverter(dtoProp.Type) : Models.PropertyType.STRING;

                        context.Properties.Add(property);
                        await context.SaveChangesAsync();
                    }
                }

                context.Database.CommitTransaction();

                response.Result.Status  = true;
                response.Result.Message = "Operation successful";
            }
            catch (Exception)
            {
                context.Database.RollbackTransaction();
            }

            return(response);
        }
Exemplo n.º 25
0
        public async Task <Models.Company> PostAsync([FromBody] Models.Company company)
        {
            var companyEntity = _mapper.Map <Company>(company);

            await _context.Companies.AddAsync(companyEntity);

            await _context.SaveChangesAsync();

            return(_mapper.Map <Models.Company>(companyEntity));
        }
Exemplo n.º 26
0
 public ActionResult Edit([Bind(Include = "ID,Name,Address")] Models.Company company)
 {
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(company));
 }
Exemplo n.º 27
0
        public async Task <CompanyDataset> GetInfo(int companyId)
        {
            Models.Company company = await _uow.CompanyRepository.GetFirst(filter : company => company.AccountId == companyId, includeProperties : "Account");

            if (company != null)
            {
                return(_mapper.Map <CompanyDataset>(company));
            }
            return(null);
        }
Exemplo n.º 28
0
        private Models.Company CreateNewCompany(CompanyDTO company, int nextId, out SerializableCompany serialized)
        {
            serialized = null;
            if (company.EntryDate == null)
            {
                Log(new CallbackParameters(CallbackReason.NullEntryDate)
                {
                    Company = company
                });
                return(null);
            }
            var entryDate = company.EntryDate.Value;

            var companyTypes = company.CompanyTypes.Where(t => t != null).Select(t => t.Value).ToList();

            serialized = SerializableCompany.Deserialize(company.Serialized);
            if (serialized != null)
            {
                if (serialized.Types != null)
                {
                    companyTypes.AddRange(serialized.Types);
                }
                if (serialized.Customer != null)
                {
                    companyTypes.Add(CompanyType.Customer);
                }
            }

            if (company.Name.EndsWith("isomedix", true, CultureInfo.InvariantCulture))
            {
                companyTypes.Add(CompanyType.TreatmentFacility);
            }
            else if (company.Name.StartsWith("sterigenics", true, CultureInfo.InvariantCulture))
            {
                companyTypes.Add(CompanyType.TreatmentFacility);
            }

            var newCompany = new Models.Company
            {
                EmployeeId = company.EmployeeId ?? _newContextHelper.DefaultEmployee.EmployeeId,
                TimeStamp  = entryDate.ConvertLocalToUTC(),

                Id = nextId,

                Name         = company.Name,
                Active       = !company.InActive,
                CompanyTypes = companyTypes.Distinct().Select(t => new CompanyTypeRecord
                {
                    CompanyId   = nextId,
                    CompanyType = (int)t
                }).ToList()
            };

            return(newCompany);
        }
 public void Remove(Models.Company toRemove)
 {
     if (toRemove.Employees != null)
     {
         foreach (var employee in toRemove.Employees)
         {
             _db.Employees.Remove(employee);
         }
     }
     _db.Companies.Remove(toRemove);
 }
Exemplo n.º 30
0
 public int Create(Company item)
 {
     Models.Company data = new Models.Company()
     {
         CompanyId = item.CompanyId,
         Name      = item.Name
     };
     db.Company.Add(data);
     db.SaveChanges();
     return(1);
 }
        public Models.Company createNewCompany(Models.User creator, Models.Company toCreate)
        {
            Models.Company company = new Models.Company()
            {
                Administrators = new List<Models.User>(),
                AllowableStorage = new List<Models.StorageAllocation>(),
                BillableItems = new List<Models.BillingType>(),
                CreatedBy = creator,
                CreatedDate = DateTime.UtcNow,
                Description = toCreate.Description,
                ID = Guid.NewGuid(),
                Name = toCreate.Name,
                Projects = new List<Models.Project>(),
                Users = new List<Models.User>()
            };

            company.Administrators.Add(creator);

            _fakeCompaniesList.Add(company);

            return company;
        }
        public Models.Company createNewCompany(Models.User creator, Models.Company toCreate)
        {
            Models.Company newCompany = new Models.Company()
            {
                Administrators = new List<Models.User>(),
                AllowableStorage = new List<Models.StorageAllocation>(),
                BillableItems = new List<Models.BillingType>(),
                CreatedBy = creator,
                CreatedDate = DateTime.UtcNow,
                Description = toCreate.Description,
                Name = toCreate.Name,
                ID = Guid.NewGuid(),
                Projects = new List<Models.Project>(),
                Users = new List<Models.User>()
            };

            SQLCompany newSqlCompany = new SQLCompany()
            {
                Name = newCompany.Name,
                CreatedByUserID = creator.ID,
                CreatedDate = newCompany.CreatedDate,
                Description = newCompany.Description,
                ID = newCompany.ID
            };

            db.SQLCompanies.Add(newSqlCompany);

            db.SaveChanges();

            return newCompany;
        }
        public Models.Company loadCompanyById(Guid companyId)
        {
            SQLCompany fromDb = db.SQLCompanies.FirstOrDefault(x => x.ID == companyId);

            Models.User companyCreator = loadUserById(fromDb.User.ID, false);

            Models.Company returnMe = new Models.Company()
            {
                CreatedBy = companyCreator,
                Administrators = new List<Models.User>(){ companyCreator },
                AllowableStorage = new List<Models.StorageAllocation>(),
                BillableItems = new List<Models.BillingType>(),
                CreatedDate = fromDb.CreatedDate,
                Description = fromDb.Description,
                ID = fromDb.ID,
                Name = fromDb.Name,
                Priorities = loadPriorityListForCompanyById(fromDb.ID),
                Projects = loadCompanyProjects(fromDb.ID),
                Users = new List<Models.User>() {  companyCreator }
            };

            return returnMe;
        }