コード例 #1
0
        public bool updateDoctor(Models.Doctor dObj)
        {
            bool status = false;

            try
            {
                CureWellDataAccessLayer.Models.Doctor doc = new CureWellDataAccessLayer.Models.Doctor();
                if (ModelState.IsValid) // If we were able to create a DAL 's Doctor type object
                {
                    // Assign incoming object 's attributes to doc's properties.
                    // Here frontend is only updating the name, but also needs to id property in order to look for the object inside dababase.
                    // Repo's updatedoc method will find obj in the database by id, then update the name.

                    doc.DoctorName = dObj.DoctorName;
                    doc.DoctorId   = dObj.DoctorId;

                    // Repo method is expecting DAL object, that's why we needed to create one and assign property value with incoming object's key/value.
                    status = rep.UpdateDoctorDetails(doc);
                }
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }
コード例 #2
0
        public bool addDoctor(Models.Doctor dObj)
        {
            bool status = false;

            // Frontend is passing in whole object.
            try
            {
                // DAL is expecting a DAL Type Doctor
                CureWellDataAccessLayer.Models.Doctor doc = new CureWellDataAccessLayer.Models.Doctor();
                // Id is columnd id, will will be generated automatially so we dont need to give.
                // Here we can do dObj.DoctorName because frontend Doctor model interface has doctorName key, it is not case sensitive, as long as it matches backend property name.

                doc.DoctorName = dObj.DoctorName;
                status         = rep.AddDoctor(doc);
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }