public async Task <IActionResult> Edit(long id, [Bind("Id,Name,Email,PhoneNumber,Fax,Address,PostalCode,CreatedAt,UpdatedAt")] Enterprises enterprises) { if (id != enterprises.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enterprises); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnterprisesExists(enterprises.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(enterprises)); }
public void WriteEnterprises(string filename) { // Creates an instance of the XmlSerializer class. XmlSerializer mySerializer = new XmlSerializer(typeof(Enterprises)); // Writing file requires a TextWriter. TextWriter writer = new StreamWriter(filename); // Creates an instance of the XmlSerializerNamespaces class. XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); // Adds namespaces and prefixes for the XML document instance. ns.Add("winery", "http://www.cohowinery.com"); ns.Add("vacationCompany", "http://www.treyresearch.com"); // Creates an instance of the class that will be serialized. Enterprises myEnterprises = new Enterprises(); // Creates objects and adds to the array. Winery w1 = new Winery(); w1.Name = "cohowinery"; Winery[] myWinery = { w1 }; myEnterprises.Wineries = myWinery; VacationCompany com1 = new VacationCompany(); com1.Name = "adventure-works"; VacationCompany[] myCompany = { com1 }; myEnterprises.Companies = myCompany; // Serializes the class, and closes the TextWriter. mySerializer.Serialize(writer, myEnterprises, ns); writer.Close(); }
public ActionResult Edit(Enterprises enterprise) { if (Request.IsAjaxRequest()) { db.Entry(enterprise).State = EntityState.Modified; db.SaveChanges(); return(Content("<b>Дані збережені о <b>" + DateTime.Now.ToLongTimeString())); } return(RedirectToAction("List")); }
/// <summary> /// מקבלת קוד עסק וכתובת מייל ובודקת האם הנתונים תקינים /// null אם כן מחזירה את העסק אחרת מחזירה /// </summary> /// <param name="code"></param> /// <param name="mail"></param> /// <returns></returns> public static EnterprisesDTO isEnterpriseExist(string code, string mail) { Enterprises enterprise = new Enterprises(); using (ClubCardsEntities db = new ClubCardsEntities()) { enterprise = db.Enterprises.FirstOrDefault(x => x.Code == code && x.Email == mail); return(enterprise != null?Conversion.EnterprisesConversion.ConvertToDTO(enterprise) : null); } }
public async Task <ActionResult> DeleteConfirmed(int id) { int cguid = GetUserIdentity(); Enterprises enterprises = await db.Enterprises.Where(w => w.GlobalContainersId == cguid || w.Id == id).FirstAsync(); enterprises._deleted = true; db.Entry(enterprises).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Id,Name,Email,PhoneNumber,Fax,Address,PostalCode,CreatedAt,UpdatedAt")] Enterprises enterprises) { if (ModelState.IsValid) { _context.Add(enterprises); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(enterprises)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Inn,Kpp,Ogrn,FAdress,YAdress,Phones")] Enterprises enterprises) { if (ModelState.IsValid) { int cguid = GetUserIdentity(); enterprises.GlobalContainersId = cguid; db.Entry(enterprises).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(enterprises)); }
public static EnterprisesDTO ConvertToDTO(Enterprises Enterprise) { EnterprisesDTO newEnterprise = new EnterprisesDTO(); newEnterprise.C_id = Enterprise.C_id; newEnterprise.Name = Enterprise.Name; newEnterprise.Email = Enterprise.Email; newEnterprise.Phone = Enterprise.Phone; newEnterprise.Code = Enterprise.Code; newEnterprise.Url = Enterprise.Name; newEnterprise.Active = Enterprise.Active; return(newEnterprise); }
public static Enterprises ConvertToEnterprises(EnterprisesDTO EnterpriseDTO) { Enterprises newEnterprise = new Enterprises(); newEnterprise.C_id = EnterpriseDTO.C_id; newEnterprise.Name = EnterpriseDTO.Name; newEnterprise.Email = EnterpriseDTO.Email; newEnterprise.Phone = EnterpriseDTO.Phone; newEnterprise.Code = EnterpriseDTO.Code; newEnterprise.Url = EnterpriseDTO.Name; newEnterprise.Active = EnterpriseDTO.Active; return(newEnterprise); }
// GET: Guides/Enterprises/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int cguid = GetUserIdentity(); Enterprises enterprises = await db.Enterprises.Where(w => w.GlobalContainersId == cguid || w.Id == id).FirstAsync(); if (enterprises == null) { return(HttpNotFound()); } return(View(enterprises)); }
public ActionResult Delete(int?id) { if (id == null) { return(HttpNotFound()); } Enterprises b = db.Enterprises.Find(id); if (b == null) { return(HttpNotFound()); } return(View(b)); }
public ActionResult DeleteConfirmed(int?id) { if (id == null) { return(HttpNotFound()); } Enterprises b = db.Enterprises.Find(id); if (b == null) { return(HttpNotFound()); } db.Enterprises.Remove(b); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Edit(int?id) { if (id == null) { return(HttpNotFound()); } Enterprises enterprise = db.Enterprises.Find(id); if (enterprise == null) { return(HttpNotFound()); } return(View(enterprise)); }
public void ReadEnterprises(string filename) { XmlSerializer mySerializer = new XmlSerializer(typeof(Enterprises)); FileStream fs = new FileStream(filename, FileMode.Open); Enterprises myEnterprises = (Enterprises) mySerializer.Deserialize(fs); for (int i = 0; i < myEnterprises.Wineries.Length; i++) { Console.WriteLine(myEnterprises.Wineries[i].Name); } for (int i = 0; i < myEnterprises.Companies.Length; i++) { Console.WriteLine(myEnterprises.Companies[i].Name); } }
public static Enterprises Convert(EnterprisesDto enterpriseDto) { if (enterpriseDto == null) { return(null); } Enterprises enterprise = new Enterprises(); enterprise.Address = enterpriseDto.Address; enterprise.Email = enterpriseDto.Email; enterprise.IDEnterprise = enterpriseDto.IDEnterprise; enterprise.NameEnterprise = enterpriseDto.NameEnterprise; enterprise.Note = enterpriseDto.Note; enterprise.Phone = enterpriseDto.Phone; enterprise.Representative = enterpriseDto.Representative; return(enterprise); }
public ActionResult List(int?id) { if (id == null) { return(HttpNotFound()); } Enterprises ent = db.Enterprises.Find(id); if (ent == null) { return(HttpNotFound()); } ent.Workforces = db.Workforces.Where(m => m.EnterprisesId == ent.Id); return(View(ent)); }
/// <summary> /// Criando um cliente para cada empresa /// </summary> private void Seed_Crm() { var letters = new[] { 'A', 'B', 'C', 'D', 'E' }; if (IsTest) { if (!Customers.Any()) { { var enterprise = Enterprises .Single(e => e.Name == "Enterprise Test"); var customer = new Customer { Enterprise = enterprise, Email = Examples.Email, Name = $"Customer Test" }; Customers.Add(customer); } foreach (var enterprise in Enterprises) { foreach (var letter in letters) { var customer = new Customer { Enterprise = enterprise, Email = Examples.Email, Name = $"Customer {letter}" }; Customers.Add(customer); } } SaveChanges(); } } }
private Enterprises CreateEnterprisesWithLinks() { var firstLink = new LinkBuilder().BuildRel(AbiquoRelations.FIRST).BuildHref(FIRST_HREF).GetLink(); var lastLink = new LinkBuilder().BuildRel(AbiquoRelations.LAST).BuildHref(LAST_HREF).GetLink(); var enterprises = new Enterprises() { Collection = new List <Enterprise>() { CreateEnterpriseWithLinks() } , Links = new List <Link>() { firstLink, lastLink } , TotalSize = 1 }; return(enterprises); }
/// <summary> /// Criando regras iniciais e de testes /// </summary> private void Seed_Security() { if (!Groups.Any()) { var groups = new Group[] { new Group { Name = "Security" }, new Group { Name = "Management" }, new Group { Name = "Configuration" }, new Group { Name = "Sales" }, new Group { Name = "Operation" } }; Groups.AddRange(groups); foreach (var enterprise in Enterprises) { var name = enterprise.Name.EndsWith('s') ? enterprise.Name + "\'s" : enterprise.Name; var group = new Group { Name = $"{name} User", Enterprise = enterprise }; Groups.Add(group); } SaveChanges(); } if (IsTest) { if (!Users.Any()) { { var enterprise = Enterprises .Single(e => e.Name == "Enterprise Test"); var email = $"user@{enterprise.Name}.com".Replace(" ", "").ToLower(); var user = new User { Name = "User", PublicId = CryptoHelper.Guid("U$1"), PrivateId = CryptoHelper.Guid("U$1"), Email = email, Password = CryptoHelper.Guid("user2019"), Enterprise = enterprise }; Users.Add(user); } foreach (var group in Groups .Where(e => e.EnterpriseId == null)) { foreach (var enterprise in Enterprises) { var email = $"{group.Name}@{enterprise.Name}.com".Replace(" ", "").ToLower(); var user = new User { Name = group.Name, PublicId = CryptoHelper.Guid(group.Name + "#" + enterprise.Name), PrivateId = CryptoHelper.Guid(group.Name + "$" + enterprise.Name), Email = email, Password = CryptoHelper.Guid(group.Name.ToLower()), Enterprise = enterprise }; Users.Add(user); var userGroup = new UserGroup { User = user, Group = group }; UserGroups.AddRange(userGroup); } } SaveChanges(); } } if (!Areas.Any()) { var areas = new Area[] { new Area { Id = (int)AreaEnum.User, Name = "User" }, new Area { Id = (int)AreaEnum.Group, Name = "Group" }, new Area { Id = (int)AreaEnum.Customer, Name = "Customer" } }; Areas.AddRange(areas); SaveChanges(); } if (IsTest) { if (!AreaAccess.Any()) { // Sales tem acesso de leitura e escrita no CRM { var area = Areas .Find((int)AreaEnum.Customer); var group = Groups .First(e => e.Name == "Sales"); var areaAccess = new AreaAccess { Area = area, Group = group, CanCreate = true, CanDelete = false, CanModify = true, CanRead = true }; AreaAccess.Add(areaAccess); } // Management tem acesso completo ao CRM { var area = Areas .Find((int)AreaEnum.Customer); var group = Groups .First(e => e.Name == "Management"); var areaAccess = new AreaAccess { Area = area, Group = group, CanCreate = true, CanDelete = true, CanModify = true, CanRead = true }; AreaAccess.Add(areaAccess); } // Operation só pode consultar o CRM { var area = Areas .Find((int)AreaEnum.Customer); var group = Groups .First(e => e.Name == "Operation"); var areaAccess = new AreaAccess { Area = area, Group = group, CanCreate = false, CanDelete = false, CanModify = false, CanRead = true }; AreaAccess.Add(areaAccess); } // Segurança pode criar novos grupos { var area = Areas .Find((int)AreaEnum.Group); var group = Groups .First(e => e.Name == "Security"); var areaAccess = new AreaAccess { Area = area, Group = group, CanCreate = true, CanDelete = true, CanModify = true, CanRead = true }; AreaAccess.Add(areaAccess); } // Segurança pode criar novos usuários { var area = Areas .Find((int)AreaEnum.User); var group = Groups .First(e => e.Name == "Security"); var areaAccess = new AreaAccess { Area = area, Group = group, CanCreate = true, CanDelete = true, CanModify = true, CanRead = true }; AreaAccess.Add(areaAccess); } SaveChanges(); } } if (!Policies.Any()) { var area = Areas .Find((int)AreaEnum.User); var policies = new Policy[] { new Policy { Id = (int)PolicyEnum.User_ChangePassword, Area = area, Name = "Change Password" }, new Policy { Id = (int)PolicyEnum.User_ChangeEmail, Area = area, Name = "Change Email" } }; Policies.AddRange(policies); SaveChanges(); } if (IsTest) { if (!PolicyAccess.Any()) { // Segurança tem acesso às políticas de segurança { var area = Areas .Find((int)AreaEnum.User); var group = Groups .First(e => e.Name == "Security"); foreach (var policy in Policies .Where(e => e.AreaId == area.Id)) { var policyAccess = new PolicyAccess { Group = group, Policy = policy }; PolicyAccess.AddRange(policyAccess); } } SaveChanges(); } } }
/// <summary> /// Drag drop /// </summary> private void treeView1_DragDrop(object sender, DragEventArgs e) { // Retrieve the client coordinates of the drop location. Point targetPoint = tvEnterprise.PointToClient(new Point(e.X, e.Y)); // Retrieve the node at the drop location. TreeNode targetNode = tvEnterprise.GetNodeAt(targetPoint); TreeNode draggedNode = new TreeNode(); if (_enterprise.Status == EntityStatus.Active || _enterprise.Status == EntityStatus.Archive || targetNode == null) { return; } draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); if (draggedNode != null) { Enterprises updateEnterprise = (Enterprises)draggedNode.Tag; if (updateEnterprise.OperationAction != OperationAction.New) { updateEnterprise.OperationAction = OperationAction.Modified; } } DataRow dataRow = (DataRow)e.Data.GetData(typeof(DataRow)); if (dataRow != null) { Enterprises enterprises = new Enterprises(dataRow); ListViewItem lstItem = new ListViewItem(enterprises.RouteName, 0); draggedNode = new TreeNode(lstItem.SubItems[0].Text); enterprises.OperationAction = OperationAction.New; draggedNode.Tag = enterprises; } // Confirm that the node at the drop location is not // the dragged node or a descendant of the dragged node. if (!draggedNode.Equals(targetNode)) { // If it is a move operation, remove the node from its current // location and add it to the node at the drop location. if (e.Effect == DragDropEffects.Move) { draggedNode.Remove(); if (targetNode.Parent == null) { targetNode.Nodes.Add(draggedNode); } else { targetNode.Parent.Nodes.Insert(targetNode.Index + 1, draggedNode); } } // If it is a copy operation, clone the dragged node // and add it to the node at the drop location. else if (e.Effect == DragDropEffects.Copy) { if (targetNode.Parent == null) { targetNode.Nodes.Add((TreeNode)draggedNode.Clone()); } else { targetNode.Parent.Nodes.Insert(targetNode.Index + 1, (TreeNode)draggedNode.Clone()); } } // Expand the node at the location // to show the dropped node. targetNode.Expand(); } }
public IEnumerable <Enterprise> GetEnterprises() { return(Enterprises.ToList()); }
// Find Enterprise by ID public Enterprise GetEnterpriseById(int id) { return(Enterprises.FirstOrDefault(ent => ent.EntId == id)); }
// Search by Rating public IEnumerable <Enterprise> GetByRating(int rating) { return(Enterprises.Where(ent => ent.Rating == rating)); }
// Search by Type public IEnumerable <Enterprise> GetByType(EnterpriceType type) { return(Enterprises.Where(ent => ent.Type == type)); }
// Search by SubName public IEnumerable <Enterprise> GetByName(string subName) { return(string.IsNullOrEmpty(subName) ? Enterprises : Enterprises.Where(ent => ent.Name.Contains(subName))); }
public ActionResult Create(Enterprises enterprise) { db.Enterprises.Add(enterprise); db.SaveChanges(); return(RedirectToAction("List")); }
/// <summary> /// Validation & Collection Data for Enterprise /// </summary> private void MapControlsToEnterprise() { if (null == _enterprise) { throw (new Exception("Error Enterprise Set")); } // TODO: Data validation _enterprise.EnterpriseName = txtEnterpriseName.Text; _enterprise.EnterpriseDescription = mmDescription.Text; _enterprise.Editor = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); _enterprise.EditTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); _enterprise.EditTimeZone = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE); TreeNode parentNode = tvEnterprise.Nodes[0]; bool blFlag = false; foreach (TreeNode node in parentNode.Nodes) { blFlag = false; Enterprises enterprises = (Enterprises)node.Tag; if (_enterprise.EnterpriseList.Count > 0) { foreach (Enterprises item in _enterprise.EnterpriseList) { if (enterprises.RouteSqenceKey == item.RouteSqenceKey) { blFlag = true; if (node.Index.ToString() != item.RouteSeqence) { item.RouteSeqence = node.Index.ToString(); item.OperationAction = OperationAction.Modified; } break; } } } //if not found the key in the list ,add this step to the route if (blFlag == false) { enterprises.RouteSeqence = node.Index.ToString(); _enterprise.EnterpriseList.Add(enterprises); } } foreach (Enterprises item in _enterprise.EnterpriseList) { blFlag = false; foreach (TreeNode node in parentNode.Nodes) { Enterprises enterprises = (Enterprises)node.Tag; if (item.RouteSqenceKey == enterprises.RouteSqenceKey) { blFlag = true; break; } } if (blFlag == false) { item.OperationAction = OperationAction.Delete; } } }