예제 #1
0
        //Added by Saddam/
        public IHttpActionResult ExecutiveDelete(ExecutiveMaster _executive)
        {
            string status = string.Empty;

            try
            {
                //worked temporary modifty after further process has done
                ExecutiveMaster _Executive = new ExecutiveMaster();
                if (_executive.ProcessTransferTo != 0)
                {
                    //_Executive = _ExecutiveService.GetExecutiveById(_executive.ProcessTransferTo);
                    //_Executive.ModifiedBy = _executive.EnteredBy;
                    //_Executive.ModifiedDate = DateTime.Now;
                    //_Executive.ProcessTransferTo = _executive.Id;
                    //_ExecutiveService.UpdateExecutive(_Executive);

                    IList <ExecutiveReporting> _repotingList = _ExecutiveService.GetRepotingListById(_executive.Id);
                    if (_repotingList.Count > 0)
                    {
                        foreach (var items in _repotingList)
                        {
                            //--delete repoting to who executive is deleted
                            ExecutiveReporting mobj_repoting = _ExecutiveService.getExecutiveReporting(items.executiveid);
                            _ExecutiveService.UpdateExecutiveReporting(mobj_repoting);

                            //--insert repoting to for which executive is deleted
                            ExecutiveReporting Reporting = new ExecutiveReporting();
                            Reporting.executiveid   = items.executiveid;
                            Reporting.reportingidto = _executive.ProcessTransferTo;
                            Reporting.EnteredBy     = _executive.EnteredBy;
                            _ExecutiveService.InsertExecutiveReporting(Reporting);
                        }
                    }


                    //--set executive repoting to or not
                    ExecutiveMaster mobj_Excutive = _ExecutiveService.GetExecutiveById(_executive.ProcessTransferTo);
                    mobj_Excutive.ProcessTransferTo = 1;
                    _ExecutiveService.UpdateExecutive(mobj_Excutive);
                    //-------------------------
                }

                _Executive = _ExecutiveService.GetExecutiveById(_executive.Id);
                //_Executive.Deactivate = "Y";
                _Executive.block             = "Y"; //for only restrict login
                _Executive.ModifiedBy        = _executive.EnteredBy;
                _Executive.ModifiedDate      = DateTime.Now;
                _Executive.ProcessTransferTo = 0;
                _ExecutiveService.UpdateExecutive(_Executive);

                status = "OK";
            }
            catch (ACSException ex)
            {
                status = ex.InnerException.Message;
            }
            catch (Exception ex)
            {
                status = ex.InnerException.Message;
            }

            return(Json(status));
        }