示例#1
0
        // DELETE: api/Manager/5
        public void Delete(int id)
        {
            Manager e = new Manager();

            e.mcid = id;
            ManagerRepository.Delete(id);
        }
示例#2
0
        private void MtEmployeeDelete_Click(object sender, EventArgs e)
        {
            if (this.dgvManager.SelectedRows.Count != 1)
            {
                MessageBox.Show("Please Select A Row First");
                return;
            }
            if (MessageBox.Show("Are You Sure?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            string appid    = this.dgvManager.CurrentRow.Cells["appid"].Value.ToString();
            bool   decision = mrepo.Delete(appid);

            if (decision)
            {
                MessageBox.Show("Delete Confirmed.");
                this.PopulateGridView();
            }
            else
            {
                MessageBox.Show("Invalid Id.");
            }
        }
示例#3
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            Manager manager = await managerRepository.FindByCondition(item => item.Id == id).FirstOrDefaultAsync();

            if (manager == null)
            {
                return(Content(HttpStatusCode.NotFound, "Manager not found"));
            }
            User user = await userRepository.FindByCondition(item => item.Id == manager.UserId).FirstOrDefaultAsync();

            if (user == null)
            {
                return(Content(HttpStatusCode.NotFound, "User not found"));
            }
            userRepository.Delete(user);
            managerRepository.Delete(manager);
            await db.SaveChangesAsync();

            return(Ok());
        }
        public async Task <Operate> DeleteById(int id)
        {
            var result = new Operate();

            try
            {
                using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    var manager = await _managerRepository.GetById(id);

                    if (manager == null)
                    {
                        result.Status  = -2;
                        result.Message = "Manager does not exist";
                        return(result);
                    }

                    //check wether customer is using mananger
                    var customer = await _customerRepository.GetByManagerId(id);

                    if (customer != null)
                    {
                        result.Status  = -3;
                        result.Message = $"Manager is used by {customer.CompanyName}";
                        return(result);
                    }

                    await _managerRepository.Delete(manager);

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Status  = -1;
                result.Message = ex.Message;
                Logger.WriteErrorLog("ManagerService", "DeleteById", ex);
            }
            return(result);
        }
示例#5
0
        public bool DeleteUser(int Id, string FIO, string position)
        {
            switch (position)
            {
            case "admin":
                AdmininRepository _ad  = new AdmininRepository();
                ComandRepository  _com = new ComandRepository();
                if (_com.GetObject(Id) != null)
                {
                    return(false);
                }
                _ad.Delete(Id);
                _ad.Save();
                return(true);

            case "employer":
                EmployeeRepository _em = new EmployeeRepository();
                if (_em.GetObject(Id).comandId != null)
                {
                    return(false);
                }
                _em.Delete(Id);
                _em.Save();
                return(true);

            case "manager":
                ManagerRepository _me = new ManagerRepository();
                if (_me.GetObject(Id).comandId != null)
                {
                    return(false);
                }
                _me.Delete(Id);
                _me.Save();
                return(true);

            default:
                return(false);
            }
        }
 /// <summary>
 ///     Delete Manager
 /// </summary>
 /// <param name="id"></param>
 public void Delete(long id)
 {
     ManagerRepository.Delete(id);
 }
示例#7
0
        public void DeleteManager(int ManagerId)
        {
            var Manager = ManagerRepository.GetById(ManagerId);

            ManagerRepository.Delete(Manager);
        }
示例#8
0
 public override void Remove(ManagerUser manager)
 {
     managerRepository.Delete(manager.id);
 }
示例#9
0
 public void Delete(Manager entity)
 => _managerRepository.Delete(entity);