Example #1
0
 public void Delete(string id)
 {
     using (OASEntities _ent = new OASEntities())
     {
         MS_Company comp = _ent.MS_Company.Find(id);
         _ent.MS_Company.Remove(comp);
         _ent.SaveChanges();
     }
 }
Example #2
0
 public MS_Company Insert(MS_Company comp)
 {
     using (OASEntities _ent = new OASEntities())
     {
         _ent.MS_Company.Add(comp);
         _ent.SaveChanges();
         return(comp);
     }
 }
Example #3
0
        public MS_Company Get(string id)
        {
            MS_Company msCompany = null;
            DataPaging <MS_Company> dataPaging = new DataPaging <MS_Company>();

            using (OASEntities _ent = new OASEntities())
            {
                msCompany = _ent.MS_Company.Find(id);
            }


            return(msCompany);
        }
Example #4
0
        public MS_Company Put(string id, MS_Company comp)
        {
            using (OASEntities _ent = new OASEntities())
            {
                MS_Company compExits = _ent.MS_Company.Find(id);

                if (compExits == null)
                {
                    throw new Exception("id:" + id + " not found ");
                }

                compExits.CompName       = comp.CompName;
                compExits.UpdateUser     = comp.UpdateUser;
                compExits.UpdateDatetime = DateTime.Now;
                _ent.SaveChanges();
                return(comp);
            }
        }
        public void CreateMsCompany(CreateMsCompanyInput input)
        {
            Logger.Info("CreateMsCompany() Started.");

            Logger.DebugFormat("CreateMsCompany() - Start checking existing code and name. Parameters sent:{0}" +
                               "coCode     = {1}{0}" +
                               "coName     = {2}"
                               , Environment.NewLine, input.coCode, input.coName);
            var checkNameCode = (from x in _msCompanyRepo.GetAll()
                                 where x.coCode == input.coCode || x.coName == input.coName
                                 select x).Count();

            Logger.DebugFormat("CreateMsCompany() - End checking existing code and name. Result:{0}", checkNameCode);

            if (checkNameCode == 0)
            {
                string imageUrl;
                if (input.image == null)
                {
                    imageUrl = "-";
                }
                else
                {
                    imageUrl = UploadImage(input.image);
                    GetURLWithoutHost(imageUrl, out imageUrl);
                }

                var data = new MS_Company
                {
                    entityID     = 1,
                    coCode       = input.coCode,
                    coName       = input.coName,
                    address      = input.address,
                    city         = "-", //hardcode for not null field
                    NPWP         = input.npwp,
                    PKP          = input.pkp,
                    PKPDate      = input.pkpDate,
                    image        = imageUrl,
                    accountNo    = "673434736", //hardcode for not null field
                    bankName     = "CIMB",
                    bankBranch   = "CIMB1",
                    mailAddress  = input.email,
                    phoneNo      = input.phoneNo,
                    faxNo        = string.IsNullOrEmpty(input.faxNo) ? "-" : input.faxNo,
                    postCodeID   = input.postCodeID,
                    NPWPAddress  = input.npwpAddress,
                    KPP_Name     = string.IsNullOrEmpty(input.kppName) ? "-" : input.kppName,
                    KPP_TTD      = string.IsNullOrEmpty(input.kppTTD) ? "-" : input.kppTTD,
                    coCodeParent = "-", //hardcode for not null field
                    APServer     = "-",
                    APcoCode     = "-",
                    APLogin      = "******",
                    isActive     = input.isActive,
                    isCA         = true // what is this?
                };
                Logger.DebugFormat("CreateMsCompany() - Start checking insert company. Parameters sent:{0}" +
                                   "	entityID	= {1}{0}"+
                                   "	coCode	    = {2}{0}"+
                                   "	coName	    = {3}{0}"+
                                   "	address	    = {4}{0}"+
                                   "	city	    = {5}{0}"+
                                   "	NPWP	    = {6}{0}"+
                                   "	PKP	        = {7}{0}"+
                                   "	PKPDate	    = {8}{0}"+
                                   "	image	    = {9}{0}"+
                                   "	accountNo	= {10}{0}"+
                                   "	bankName	= {11}{0}"+
                                   "	bankBranch	= {12}{0}"+
                                   "	mailAddress	= {13}{0}"+
                                   "	phoneNo	    = {14}{0}"+
                                   "	faxNo	    = {15}{0}"+
                                   "	postCodeID	= {16}{0}"+
                                   "	NPWPAddress	= {17}{0}"+
                                   "	KPP_Name	= {18}{0}"+
                                   "	KPP_TTD	    = {19}{0}"+
                                   "	coCodeParent= {20}{0}"+
                                   "	APServer	= {21}{0}"+
                                   "	APcoCode	= {22}{0}"+
                                   "	APLogin	    = {23}{0}"+
                                   "	isActive	= {24}{0}"+
                                   "	isCA	    = {25}"
                                   , Environment.NewLine, 1, input.coCode, input.coName, input.address, "-", input.npwp, input.pkp, input.pkpDate, imageUrl
                                   , "673434736", "CIMB", "CIMB1", input.email, input.phoneNo, input.faxNo, input.postCodeID, input.npwpAddress, input.kppName
                                   , input.kppTTD, "-t", "-", "-", "-", input.isActive, true);

                _msCompanyRepo.Insert(data);

                Logger.DebugFormat("CreateMsCompany() - End insert company.");
            }
            else
            {
                Logger.ErrorFormat("CreateMsCompany() ERROR. Result = {0}", "Company Code or Company Name Already Exist !");
                throw new UserFriendlyException("Company Code or Company Name Already Exist !");
            }
            Logger.Info("CreateMsCompany() Finished.");
        }